Micron Document
Fox's Git Mirrors

Node / acehoss / PyTCP.git / commits / 86c8b85

Commit 86c8b85f15a7c054c99f8d0d879e1513c6778f17


Parents : c199e25
Author : Sebastian Majewski <ccie18643@gmail.com>
Date : 2022-11-21T17:39:12-06:00

Fixed type errors.

Changes

65 files changed, 756 insertions(+), 588 deletions(-)

M setup.cfg +11 -2

Diff

diff --git a/examples/icmp_echo_client.py b/examples/icmp_echo_client.py
index 89f16ae..8ecdf07 100755
--- a/examples/icmp_echo_client.py
+++ b/examples/icmp_echo_client.py
@@ -137,7 +137,7 @@ class IcmpEchoClient:
@click.command()
@click.option("--interface", default="tap7")
@click.argument("remote_ip_address")
-def cli(*, interface: str, remote_ip_address: str):
+def cli(*, interface: str, remote_ip_address: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the ICMP Echo client.

diff --git a/examples/tcp_daytime_service.py b/examples/tcp_daytime_service.py
index 38f85af..f636fbb 100755
--- a/examples/tcp_daytime_service.py
+++ b/examples/tcp_daytime_service.py
@@ -111,7 +111,7 @@ class TcpDaytimeService(TcpService):
@click.command()
@click.option("--interface", default="tap7")
-def cli(*, interface: str):
+def cli(*, interface: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the TCP Daytime service.

diff --git a/examples/tcp_discard_service.py b/examples/tcp_discard_service.py
index 7800b91..dc6bf09 100755
--- a/examples/tcp_discard_service.py
+++ b/examples/tcp_discard_service.py
@@ -118,7 +118,7 @@ class TcpDiscardService(TcpService):
@click.command()
@click.option("--interface", default="tap7")
-def cli(*, interface: str):
+def cli(*, interface: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the TCP Discard service.

diff --git a/examples/tcp_echo_client.py b/examples/tcp_echo_client.py
index 3c2c3b6..4860416 100755
--- a/examples/tcp_echo_client.py
+++ b/examples/tcp_echo_client.py
@@ -55,7 +55,7 @@ class TcpEchoClient:
local_ip_address: str = "0.0.0.0",
remote_ip_address: str,
local_port: int = 0,
- remote_port=7,
+ remote_port: int = 7,
message_count: int = -1,
message_delay: int = 1,
message_size: int = 5,
@@ -171,7 +171,7 @@ class TcpEchoClient:
@click.command()
@click.option("--interface", default="tap7")
@click.argument("remote_ip_address")
-def cli(*, interface: str, remote_ip_address: str):
+def cli(*, interface: str, remote_ip_address: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the TCP Echo client.

diff --git a/examples/tcp_echo_service.py b/examples/tcp_echo_service.py
index 3546598..b5f16d0 100755
--- a/examples/tcp_echo_service.py
+++ b/examples/tcp_echo_service.py
@@ -129,7 +129,7 @@ class TcpEchoService(TcpService):
@click.command()
@click.option("--interface", default="tap7")
-def cli(*, interface: str):
+def cli(*, interface: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the TCP Echo service.

diff --git a/examples/udp_daytime_service.py b/examples/udp_daytime_service.py
index d7af9fe..2e78a8d 100755
--- a/examples/udp_daytime_service.py
+++ b/examples/udp_daytime_service.py
@@ -81,7 +81,7 @@ class UdpDaytimeService(UdpService):
@click.command()
@click.option("--interface", default="tap7")
-def cli(*, interface: str):
+def cli(*, interface: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the UDP Daytime service.

diff --git a/examples/udp_discard_service.py b/examples/udp_discard_service.py
index 8695981..41c948a 100755
--- a/examples/udp_discard_service.py
+++ b/examples/udp_discard_service.py
@@ -78,7 +78,7 @@ class UdpDiscardService(UdpService):
@click.command()
@click.option("--interface", default="tap7")
-def cli(*, interface: str):
+def cli(*, interface: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the UDP Discard service.

diff --git a/examples/udp_echo_client.py b/examples/udp_echo_client.py
index de312ff..9ae0e3c 100755
--- a/examples/udp_echo_client.py
+++ b/examples/udp_echo_client.py
@@ -165,7 +165,7 @@ class UdpEchoClient:
@click.command()
@click.option("--interface", default="tap7")
@click.argument("remote_ip_address")
-def cli(*, interface: str, remote_ip_address: str):
+def cli(*, interface: str, remote_ip_address: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the TCP Echo client.

diff --git a/examples/udp_echo_service.py b/examples/udp_echo_service.py
index 9ee3d82..7520682 100755
--- a/examples/udp_echo_service.py
+++ b/examples/udp_echo_service.py
@@ -94,7 +94,7 @@ class UdpEchoService(UdpService):
@click.command()
@click.option("--interface", default="tap7")
-def cli(*, interface: str):
+def cli(*, interface: str) -> None:
"""
Start PyTCP stack and stop it when user presses Ctrl-C.
Run the UDP Echo service.

diff --git a/pytcp/__init__.py b/pytcp/__init__.py
index 8a4fa90..8dcb142 100755
--- a/pytcp/__init__.py
+++ b/pytcp/__init__.py
@@ -67,7 +67,7 @@ class TcpIpStack:
struct.pack("16sH", interface.encode(), IFF_TAP | IFF_NO_PI),
)
- def start(self):
+ def start(self) -> None:
"""
Start stack components.
"""
@@ -81,7 +81,7 @@ class TcpIpStack:
stack.packet_handler.assign_ip4_addresses()
stack.packet_handler.log_stack_address_info()
- def stop(self):
+ def stop(self) -> None:
"""
Stop stack components.
"""

diff --git a/pytcp/misc/ip_helper.py b/pytcp/misc/ip_helper.py
index e2f1659..b95024a 100755
--- a/pytcp/misc/ip_helper.py
+++ b/pytcp/misc/ip_helper.py
@@ -49,9 +49,9 @@ def inet_cksum(data: memoryview, init: int = 0) -> int:
Compute Internet Checksum used by IPv4/ICMPv4/ICMPv6/UDP/TCP protocols.
"""
if (dlen := len(data)) == 20:
- cksum = init + sum(struct.unpack("!5L", data))
+ cksum = init + int(sum(struct.unpack("!5L", data)))
else:
- cksum = init + sum(struct.unpack_from(f"!{dlen >> 3}Q", data))
+ cksum = init + int(sum(struct.unpack_from(f"!{dlen >> 3}Q", data)))
if remainder := dlen & 7:
cksum += int().from_bytes(data[-remainder:], byteorder="big") << (
(8 - remainder) << 3

diff --git a/pytcp/misc/packet_stats.py b/pytcp/misc/packet_stats.py
index 69f2c9d..4d732ad 100755
--- a/pytcp/misc/packet_stats.py
+++ b/pytcp/misc/packet_stats.py
@@ -115,7 +115,10 @@ class PacketStatsRx:
tcp__socket_match_listening__forward_to_socket: int = 0
tcp__no_socket_match__respond_rst: int = 0
- def __eq__(self, other):
+ def __eq__(self, other: object) -> bool:
+ """
+ The '__eq__()' dunder.
+ """
return repr(self) == repr(other)
@@ -222,5 +225,8 @@ class PacketStatsTx:
udp__send: int = 0
udp__unknown__drop: int = 0
- def __eq__(self, other):
+ def __eq__(self, other: object) -> bool:
+ """
+ The '__eq__()' dunder.
+ """
return repr(self) == repr(other)

diff --git a/pytcp/misc/tx_status.py b/pytcp/misc/tx_status.py
index 50717cd..b8e874a 100755
--- a/pytcp/misc/tx_status.py
+++ b/pytcp/misc/tx_status.py
@@ -87,13 +87,13 @@ class TxStatus(Enum):
"""
return str(self.name)
- def __eq__(self, other):
+ def __eq__(self, other: object) -> bool:
"""
- The '__repr__()' dunder.
+ The '__eq__()' dunder.
"""
return repr(self) == repr(other)
- def __hash__(self):
+ def __hash__(self) -> int:
"""
The '__hash__()' dunder.
"""

diff --git a/pytcp/protocols/arp/phrx.py b/pytcp/protocols/arp/phrx.py
index b8badad..db1d99d 100755
--- a/pytcp/protocols/arp/phrx.py
+++ b/pytcp/protocols/arp/phrx.py
@@ -43,9 +43,10 @@ from pytcp.protocols.arp.ps import ARP_OP_REPLY, ARP_OP_REQUEST
if TYPE_CHECKING:
from pytcp.misc.packet import PacketRx
+ from pytcp.subsystems.packet_handler import PacketHandler
-def _phrx_arp(self, packet_rx: PacketRx) -> None:
+def _phrx_arp(self: PacketHandler, packet_rx: PacketRx) -> None:
"""
Handle inbound ARP packets.
"""
@@ -71,7 +72,7 @@ def _phrx_arp(self, packet_rx: PacketRx) -> None:
# Check if request contains our IP address in SPA field,
# this indicates IP address conflict
if packet_rx.arp.spa in self.ip4_unicast:
- self.packet_stats_rx.arp__op_request_ip_conflict += 1
+ self.packet_stats_rx.arp__op_request__ip_conflict += 1
if __debug__:
log(
"arp",

diff --git a/pytcp/protocols/arp/phtx.py b/pytcp/protocols/arp/phtx.py
index e9da17e..dfcd2e5 100755
--- a/pytcp/protocols/arp/phtx.py
+++ b/pytcp/protocols/arp/phtx.py
@@ -45,10 +45,11 @@ from pytcp.protocols.arp.ps import ARP_OP_REPLY, ARP_OP_REQUEST
if TYPE_CHECKING:
from pytcp.lib.ip4_address import Ip4Address
+ from pytcp.subsystems.packet_handler import PacketHandler
def _phtx_arp(
- self,
+ self: PacketHandler,
*,
ether_src: MacAddress,
ether_dst: MacAddress,

diff --git a/pytcp/protocols/ether/fpa.py b/pytcp/protocols/ether/fpa.py
index aa99f15..aae66b1 100755
--- a/pytcp/protocols/ether/fpa.py
+++ b/pytcp/protocols/ether/fpa.py
@@ -51,7 +51,7 @@ from pytcp.protocols.raw.fpa import RawAssembler
if TYPE_CHECKING:
from pytcp.lib.tracker import Tracker
from pytcp.protocols.arp.fpa import ArpAssembler
- from pytcp.protocols.ip4.fpa import Ip4Assembler
+ from pytcp.protocols.ip4.fpa import Ip4Assembler, Ip4FragAssembler
from pytcp.protocols.ip6.fpa import Ip6Assembler
@@ -67,6 +67,7 @@ class EtherAssembler:
dst: MacAddress = MacAddress(0),
carried_packet: ArpAssembler
| Ip4Assembler
+ | Ip4FragAssembler
| Ip6Assembler
| RawAssembler = RawAssembler(),
) -> None:
@@ -81,7 +82,7 @@ class EtherAssembler:
ETHER_TYPE_RAW,
}, f"{carried_packet.ether_type=}"
- self._carried_packet: ArpAssembler | Ip4Assembler | Ip6Assembler | RawAssembler = (
+ self._carried_packet: ArpAssembler | Ip4Assembler | Ip4FragAssembler | Ip6Assembler | RawAssembler = (
carried_packet
)
self._tracker: Tracker = self._carried_packet.tracker
@@ -119,7 +120,7 @@ class EtherAssembler:
return self._dst
@dst.setter
- def dst(self, mac_address: MacAddress):
+ def dst(self, mac_address: MacAddress) -> None:
"""
Setter for the '_dst' attribute.
"""
@@ -133,7 +134,7 @@ class EtherAssembler:
return self._src
@src.setter
- def src(self, mac_address: MacAddress):
+ def src(self, mac_address: MacAddress) -> None:
"""
Setter for the '_src' attribute.
"""

diff --git a/pytcp/protocols/ether/phrx.py b/pytcp/protocols/ether/phrx.py
index 3ca9d61..5adb1c2 100755
--- a/pytcp/protocols/ether/phrx.py
+++ b/pytcp/protocols/ether/phrx.py
@@ -36,6 +36,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
import pytcp.config as config
+from pytcp.lib.logger import log
from pytcp.protocols.ether.fpp import EtherParser
from pytcp.protocols.ether.ps import (
ETHER_TYPE_ARP,
@@ -45,11 +46,10 @@ from pytcp.protocols.ether.ps import (
if TYPE_CHECKING:
from pytcp.misc.packet import PacketRx
-
-from pytcp.lib.logger import log
+ from pytcp.subsystems.packet_handler import PacketHandler
-def _phrx_ether(self, packet_rx: PacketRx) -> None:
+def _phrx_ether(self: PacketHandler, packet_rx: PacketRx) -> None:
"""
Handle inbound Ethernet packets.
"""

diff --git a/pytcp/protocols/ether/phtx.py b/pytcp/protocols/ether/phtx.py
index c856a16..dfde842 100755
--- a/pytcp/protocols/ether/phtx.py
+++ b/pytcp/protocols/ether/phtx.py
@@ -46,15 +46,23 @@ from pytcp.protocols.raw.fpa import RawAssembler
if TYPE_CHECKING:
from pytcp.protocols.arp.fpa import ArpAssembler
+ from pytcp.subsystems.packet_handler import PacketHandler
+
+
+def _send_out_packet(ether_packet_tx: EtherAssembler) -> None:
+ if __debug__:
+ log("ether", f"{ether_packet_tx.tracker} - {ether_packet_tx}")
+ stack.tx_ring.enqueue(ether_packet_tx)
def _phtx_ether(
- self,
+ self: PacketHandler,
*,
ether_src: MacAddress = MacAddress(0),
ether_dst: MacAddress = MacAddress(0),
carried_packet: ArpAssembler
| Ip4Assembler
+ | Ip4FragAssembler
| Ip6Assembler
| RawAssembler
| None = None,
@@ -63,11 +71,6 @@ def _phtx_ether(
Handle outbound Ethernet packets.
"""
- def _send_out_packet() -> None:
- if __debug__:
- log("ether", f"{ether_packet_tx.tracker} - {ether_packet_tx}")
- stack.tx_ring.enqueue(ether_packet_tx)
-
if carried_packet is None:
carried_packet = RawAssembler()
@@ -105,7 +108,7 @@ def _phtx_ether(
f"{ether_packet_tx.tracker} - Contains valid destination "
"MAC address",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
# Check if we can obtain destination MAC based on IPv6 header data
@@ -127,7 +130,7 @@ def _phtx_ether(
f"{ether_packet_tx.tracker} - Resolved destination IPv6 "
f"{ip6_dst} to MAC {ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
# Send out packet if is destined to external network (in relation to
@@ -159,7 +162,7 @@ def _phtx_ether(
f"IPv6 {ip6_dst}"
f" to Default Gateway MAC {ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
self.packet_stats_tx.ether__dst_unspec__ip6_lookup__extnet__gw_nd_cache_miss__drop += (
1
@@ -179,7 +182,7 @@ def _phtx_ether(
f"{ether_packet_tx.tracker} - Resolved destination IPv6 "
f"{ip6_dst} to MAC {ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
else:
self.packet_stats_tx.ether__dst_unspec__ip6_lookup__locnet__nd_cache_miss__drop += (
@@ -214,7 +217,7 @@ def _phtx_ether(
f"{ether_packet_tx.tracker} - Resolved destination IPv4 "
f"{ip4_dst} to MAC {ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
# Send out packet if its destinied to limited broadcast addresses
@@ -229,7 +232,7 @@ def _phtx_ether(
f"{ether_packet_tx.tracker} - Resolved destination IPv4 "
f"{ip4_dst} to MAC {ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
# Send out packet if its destinied to network broadcast or network
@@ -250,7 +253,7 @@ def _phtx_ether(
f"{ether_packet_tx.tracker} - Resolved destination "
f"IPv4 {ip4_dst} to MAC {ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
# Send out packet if is destined to external network (in relation to
@@ -282,7 +285,7 @@ def _phtx_ether(
f"IPv4 {ip4_dst} to Default Gateway MAC "
f"{ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
self.packet_stats_tx.ether__dst_unspec__ip4_lookup__extnet__gw_arp_cache_miss__drop += (
1
@@ -302,7 +305,7 @@ def _phtx_ether(
f"{ether_packet_tx.tracker} - Resolved destination IPv4 "
f"{ip4_dst} to MAC {ether_packet_tx.dst}",
)
- _send_out_packet()
+ _send_out_packet(ether_packet_tx)
return TxStatus.PASSED__ETHER__TO_TX_RING
else:
self.packet_stats_tx.ether__dst_unspec__ip4_lookup__locnet__arp_cache_miss__drop += (

diff --git a/pytcp/protocols/icmp4/phrx.py b/pytcp/protocols/icmp4/phrx.py
index aa28369..35a0661 100755
--- a/pytcp/protocols/icmp4/phrx.py
+++ b/pytcp/protocols/icmp4/phrx.py
@@ -51,9 +51,10 @@ from pytcp.protocols.udp.ps import UDP_HEADER_LEN
if TYPE_CHECKING:
from pytcp.misc.packet import PacketRx
+ from pytcp.subsystems.packet_handler import PacketHandler
-def _phrx_icmp4(self, packet_rx: PacketRx) -> None:
+def _phrx_icmp4(self: PacketHandler, packet_rx: PacketRx) -> None:
"""Handle inbound ICMPv4 packets"""
self.packet_stats_rx.icmp4__pre_parse += 1

diff --git a/pytcp/protocols/icmp4/phtx.py b/pytcp/protocols/icmp4/phtx.py
index 4a9ed52..0026ae2 100755
--- a/pytcp/protocols/icmp4/phtx.py
+++ b/pytcp/protocols/icmp4/phtx.py
@@ -48,10 +48,11 @@ from pytcp.protocols.icmp4.ps import (
if TYPE_CHECKING:
from pytcp.lib.ip4_address import Ip4Address
+ from pytcp.subsystems.packet_handler import PacketHandler
def _phtx_icmp4(
- self,
+ self: PacketHandler,
*,
ip4_src: Ip4Address,
ip4_dst: Ip4Address,

diff --git a/pytcp/protocols/icmp6/fpa.py b/pytcp/protocols/icmp6/fpa.py
index 1f73246..e36e04c 100755
--- a/pytcp/protocols/icmp6/fpa.py
+++ b/pytcp/protocols/icmp6/fpa.py
@@ -529,7 +529,7 @@ class Icmp6NdOptSLLA:
bytes(self._slla),
)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -576,7 +576,7 @@ class Icmp6NdOptTLLA:
bytes(self._tlla),
)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -657,7 +657,7 @@ class Icmp6NdOptPI:
bytes(self._prefix.address),
)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""

diff --git a/pytcp/protocols/icmp6/phrx.py b/pytcp/protocols/icmp6/phrx.py
index 4947c27..dfdd754 100755
--- a/pytcp/protocols/icmp6/phrx.py
+++ b/pytcp/protocols/icmp6/phrx.py
@@ -56,9 +56,10 @@ from pytcp.protocols.udp.ps import UDP_HEADER_LEN
if TYPE_CHECKING:
from pytcp.misc.packet import PacketRx
+ from pytcp.subsystems.packet_handler import PacketHandler
-def _phrx_icmp6(self, packet_rx: PacketRx) -> None:
+def _phrx_icmp6(self: PacketHandler, packet_rx: PacketRx) -> None:
"""
Handle inbound ICMPv6 packets.
"""

diff --git a/pytcp/protocols/icmp6/phtx.py b/pytcp/protocols/icmp6/phtx.py
index dd1bd10..d1fb2cd 100755
--- a/pytcp/protocols/icmp6/phtx.py
+++ b/pytcp/protocols/icmp6/phtx.py
@@ -39,6 +39,7 @@ from pytcp.lib.logger import log
from pytcp.lib.tracker import Tracker
from pytcp.protocols.icmp6.fpa import (
Icmp6Assembler,
+ Icmp6MulticastAddressRecord,
Icmp6NdOptPI,
Icmp6NdOptSLLA,
Icmp6NdOptTLLA,
@@ -58,10 +59,11 @@ from pytcp.protocols.icmp6.ps import (
if TYPE_CHECKING:
from pytcp.lib.ip6_address import Ip6Address
from pytcp.misc.tx_status import TxStatus
+ from pytcp.subsystems.packet_handler import PacketHandler
def _phtx_icmp6(
- self,
+ self: PacketHandler,
*,
ip6_src: Ip6Address,
ip6_dst: Ip6Address,
@@ -79,7 +81,8 @@ def _phtx_icmp6(
icmp6_na_target_address: Ip6Address | None = None,
icmp6_nd_options: list[Icmp6NdOptSLLA | Icmp6NdOptTLLA | Icmp6NdOptPI]
| None = None,
- icmp6_mlr2_multicast_address_record=None,
+ icmp6_mlr2_multicast_address_record: list[Icmp6MulticastAddressRecord]
+ | None = None,
echo_tracker: Tracker | None = None,
) -> TxStatus:
"""

diff --git a/pytcp/protocols/ip4/fpa.py b/pytcp/protocols/ip4/fpa.py
index 778a5ee..6236341 100755
--- a/pytcp/protocols/ip4/fpa.py
+++ b/pytcp/protocols/ip4/fpa.py
@@ -411,7 +411,7 @@ class Ip4OptEol:
"""
return struct.pack("!B", IP4_OPT_EOL)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -447,7 +447,7 @@ class Ip4OptNop:
"""
return struct.pack("!B", IP4_OPT_NOP)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""

diff --git a/pytcp/protocols/ip4/fpp.py b/pytcp/protocols/ip4/fpp.py
index 406253f..eb56827 100755
--- a/pytcp/protocols/ip4/fpp.py
+++ b/pytcp/protocols/ip4/fpp.py
@@ -311,7 +311,9 @@ class Ip4Parser:
self.proto,
self.plen - self.hlen,
)
- self._cache__pshdr_sum = sum(struct.unpack("! 3L", pseudo_header))
+ self._cache__pshdr_sum = int(
+ sum(struct.unpack("! 3L", pseudo_header))
+ )
return self._cache__pshdr_sum
def _packet_integrity_check(self) -> str:

diff --git a/pytcp/protocols/ip4/phrx.py b/pytcp/protocols/ip4/phrx.py
index 39e0838..7fbe663 100755
--- a/pytcp/protocols/ip4/phrx.py
+++ b/pytcp/protocols/ip4/phrx.py
@@ -35,6 +35,7 @@ from __future__ import annotations
import struct
from time import time
+from typing import TYPE_CHECKING
import pytcp.config as config
from pytcp.lib.logger import log
@@ -48,8 +49,13 @@ from pytcp.protocols.ip4.ps import (
IP4_PROTO_UDP,
)
+if TYPE_CHECKING:
+ from pytcp.subsystems.packet_handler import PacketHandler
-def _defragment_ip4_packet(self, packet_rx: PacketRx) -> PacketRx | None:
+
+def _defragment_ip4_packet(
+ self: PacketHandler, packet_rx: PacketRx
+) -> PacketRx | None:
"""
Defragment IPv4 packet.
"""
@@ -122,7 +128,7 @@ def _defragment_ip4_packet(self, packet_rx: PacketRx) -> PacketRx | None:
return packet_rx
-def _phrx_ip4(self, packet_rx: PacketRx) -> None:
+def _phrx_ip4(self: PacketHandler, packet_rx: PacketRx) -> None:
"""Handle inbound IPv4 packets"""
self.packet_stats_rx.ip4__pre_parse += 1
@@ -170,9 +176,12 @@ def _phrx_ip4(self, packet_rx: PacketRx) -> None:
# Check if packet is a fragment and if so process it accordingly
if packet_rx.ip4.offset != 0 or packet_rx.ip4.flag_mf:
self.packet_stats_rx.ip4__frag += 1
- if not (packet_rx := self._defragment_ip4_packet(packet_rx)):
+ if not (
+ defragmented_packet_rx := self._defragment_ip4_packet(packet_rx)
+ ):
return
else:
+ packet_rx = defragmented_packet_rx
self.packet_stats_rx.ip4__defrag += 1
if packet_rx.ip4.proto == IP4_PROTO_ICMP4:

diff --git a/pytcp/protocols/ip4/phtx.py b/pytcp/protocols/ip4/phtx.py
index cc253c5..d0783ac 100755
--- a/pytcp/protocols/ip4/phtx.py
+++ b/pytcp/protocols/ip4/phtx.py
@@ -45,14 +45,20 @@ from pytcp.protocols.raw.fpa import RawAssembler
from pytcp.protocols.udp.fpa import UdpAssembler
if TYPE_CHECKING:
+ from pytcp.lib.tracker import Tracker
from pytcp.protocols.tcp.fpa import TcpAssembler
+ from pytcp.subsystems.packet_handler import PacketHandler
def _validate_src_ip4_address(
- self,
+ self: PacketHandler,
ip4_src: Ip4Address,
ip4_dst: Ip4Address,
- carried_packet: Icmp4Assembler | TcpAssembler | UdpAssembler | RawAssembler,
+ carried_packet: Icmp4Assembler
+ | TcpAssembler
+ | UdpAssembler
+ | Ip4FragAssembler
+ | RawAssembler,
) -> Ip4Address | TxStatus:
"""
Make sure source ip address is valid, supplement with valid one
@@ -208,7 +214,7 @@ def _validate_src_ip4_address(
def _validate_dst_ip4_address(
- self, ip4_dst: Ip4Address, tracker
+ self: PacketHandler, ip4_dst: Ip4Address, tracker: Tracker
) -> Ip4Address | TxStatus:
"""Make sure destination ip address is valid"""
@@ -227,7 +233,7 @@ def _validate_dst_ip4_address(
def _phtx_ip4(
- self,
+ self: PacketHandler,
*,
ip4_dst: Ip4Address,
ip4_src: Ip4Address,

diff --git a/pytcp/protocols/ip6/fpp.py b/pytcp/protocols/ip6/fpp.py
index 2c11fda..7ff1d85 100755
--- a/pytcp/protocols/ip6/fpp.py
+++ b/pytcp/protocols/ip6/fpp.py
@@ -225,7 +225,10 @@ class Ip6Parser:
0,
self.next,
)
- self._cache__pshdr_sum = sum(struct.unpack("! 5Q", pseudo_header))
+ self._cache__pshdr_sum = int(
+ sum(struct.unpack("! 5Q", pseudo_header))
+ )
+
return self._cache__pshdr_sum
def _packet_integrity_check(self) -> str:

diff --git a/pytcp/protocols/ip6/phrx.py b/pytcp/protocols/ip6/phrx.py
index 5fb48be..ef78db2 100755
--- a/pytcp/protocols/ip6/phrx.py
+++ b/pytcp/protocols/ip6/phrx.py
@@ -33,6 +33,8 @@
from __future__ import annotations
+from typing import TYPE_CHECKING
+
from pytcp.lib.logger import log
from pytcp.misc.packet import PacketRx
from pytcp.protocols.ip6.fpp import Ip6Parser
@@ -43,8 +45,11 @@ from pytcp.protocols.ip6.ps import (
IP6_NEXT_UDP,
)
+if TYPE_CHECKING:
+ from pytcp.subsystems.packet_handler import PacketHandler
+
-def _phrx_ip6(self, packet_rx: PacketRx) -> None:
+def _phrx_ip6(self: PacketHandler, packet_rx: PacketRx) -> None:
"""
Handle inbound IPv6 packets.
"""

diff --git a/pytcp/protocols/ip6/phtx.py b/pytcp/protocols/ip6/phtx.py
index b0ca38e..aaa594c 100755
--- a/pytcp/protocols/ip6/phtx.py
+++ b/pytcp/protocols/ip6/phtx.py
@@ -48,13 +48,15 @@ from pytcp.protocols.ip6.fpa import Ip6Assembler
from pytcp.protocols.raw.fpa import RawAssembler
if TYPE_CHECKING:
+ from pytcp.lib.tracker import Tracker
from pytcp.protocols.ip6_ext_frag.fpa import Ip6ExtFragAssembler
from pytcp.protocols.tcp.fpa import TcpAssembler
from pytcp.protocols.udp.fpa import UdpAssembler
+ from pytcp.subsystems.packet_handler import PacketHandler
def _validate_src_ip6_address(
- self,
+ self: PacketHandler,
ip6_src: Ip6Address,
ip6_dst: Ip6Address,
carried_packet: Ip6ExtFragAssembler
@@ -187,7 +189,7 @@ def _validate_src_ip6_address(
def _validate_dst_ip6_address(
- self, ip6_dst: Ip6Address, tracker
+ self: PacketHandler, ip6_dst: Ip6Address, tracker: Tracker
) -> Ip6Address | TxStatus:
"""Make sure destination ip address is valid"""
@@ -206,7 +208,7 @@ def _validate_dst_ip6_address(
def _phtx_ip6(
- self,
+ self: PacketHandler,
*,
ip6_dst: Ip6Address,
ip6_src: Ip6Address,

diff --git a/pytcp/protocols/ip6_ext_frag/phrx.py b/pytcp/protocols/ip6_ext_frag/phrx.py
index c38e4a6..d994fde 100755
--- a/pytcp/protocols/ip6_ext_frag/phrx.py
+++ b/pytcp/protocols/ip6_ext_frag/phrx.py
@@ -36,14 +36,20 @@ from __future__ import annotations
import struct
from time import time
+from typing import TYPE_CHECKING
import pytcp.config as config
from pytcp.lib.logger import log
from pytcp.misc.packet import PacketRx
from pytcp.protocols.ip6_ext_frag.fpp import Ip6ExtFragParser
+if TYPE_CHECKING:
+ from pytcp.subsystems.packet_handler import PacketHandler
-def _defragment_ip6_packet(self, packet_rx: PacketRx) -> PacketRx | None:
+
+def _defragment_ip6_packet(
+ self: PacketHandler, packet_rx: PacketRx
+) -> PacketRx | None:
"""
Defragment IPv6 packet.
"""
@@ -116,7 +122,7 @@ def _defragment_ip6_packet(self, packet_rx: PacketRx) -> PacketRx | None:
return packet_rx
-def _phrx_ip6_ext_frag(self, packet_rx: PacketRx) -> None:
+def _phrx_ip6_ext_frag(self: PacketHandler, packet_rx: PacketRx) -> None:
"""
Handle inbound IPv6 fragment extension header.
"""
@@ -137,6 +143,6 @@ def _phrx_ip6_ext_frag(self, packet_rx: PacketRx) -> None:
if __debug__:
log("ip6", f"{packet_rx.tracker} - {packet_rx.ip6_ext_frag}")
- if packet_rx := self._defragment_ip6_packet(packet_rx):
+ if defragmented_packet_rx := self._defragment_ip6_packet(packet_rx):
self.packet_stats_rx.ip6_ext_frag__defrag += 1
- self._phrx_ip6(packet_rx)
+ self._phrx_ip6(defragmented_packet_rx)

diff --git a/pytcp/protocols/ip6_ext_frag/phtx.py b/pytcp/protocols/ip6_ext_frag/phtx.py
index e0a9ebd..0f905b0 100755
--- a/pytcp/protocols/ip6_ext_frag/phtx.py
+++ b/pytcp/protocols/ip6_ext_frag/phtx.py
@@ -44,9 +44,12 @@ from pytcp.protocols.ip6_ext_frag.ps import IP6_EXT_FRAG_HEADER_LEN
if TYPE_CHECKING:
from pytcp.protocols.ip6.fpa import Ip6Assembler
+ from pytcp.subsystems.packet_handler import PacketHandler
-def _phtx_ip6_ext_frag(self, *, ip6_packet_tx: Ip6Assembler) -> TxStatus:
+def _phtx_ip6_ext_frag(
+ self: PacketHandler, *, ip6_packet_tx: Ip6Assembler
+) -> TxStatus:
"""
Handle outbound IPv6 fagment extension header.
"""

diff --git a/pytcp/protocols/raw/fpa.py b/pytcp/protocols/raw/fpa.py
index 2078e2a..afbcbe2 100755
--- a/pytcp/protocols/raw/fpa.py
+++ b/pytcp/protocols/raw/fpa.py
@@ -78,7 +78,7 @@ class RawAssembler:
"""
return f"RawAssembler(data={self._data!r})"
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""

diff --git a/pytcp/protocols/tcp/fpa.py b/pytcp/protocols/tcp/fpa.py
index e95353c..41fbcd2 100755
--- a/pytcp/protocols/tcp/fpa.py
+++ b/pytcp/protocols/tcp/fpa.py
@@ -241,7 +241,7 @@ class TcpOptEol:
"""
return struct.pack("!B", TCP_OPT_EOL)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -277,7 +277,7 @@ class TcpOptNop:
"""
return struct.pack("!B", TCP_OPT_NOP)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -320,7 +320,7 @@ class TcpOptMss:
"""
return struct.pack("! BB H", TCP_OPT_MSS, TCP_OPT_MSS_LEN, self._mss)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -365,7 +365,7 @@ class TcpOptWscale:
"! BB B", TCP_OPT_WSCALE, TCP_OPT_WSCALE_LEN, self._wscale
)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -401,7 +401,7 @@ class TcpOptSackPerm:
"""
return struct.pack("! BB", TCP_OPT_SACKPERM, TCP_OPT_SACKPERM_LEN)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""
@@ -452,7 +452,7 @@ class TcpOptTimestamp:
self._tsecr,
)
- def __eq__(self, other) -> bool:
+ def __eq__(self, other: object) -> bool:
"""
Equal operator.
"""

diff --git a/pytcp/protocols/tcp/phrx.py b/pytcp/protocols/tcp/phrx.py
index c422d4c..e88db4f 100755
--- a/pytcp/protocols/tcp/phrx.py
+++ b/pytcp/protocols/tcp/phrx.py
@@ -33,14 +33,19 @@
from __future__ import annotations
+from typing import TYPE_CHECKING
+
import pytcp.misc.stack as stack
from pytcp.lib.logger import log
from pytcp.misc.packet import PacketRx
from pytcp.protocols.tcp.fpp import TcpParser
from pytcp.protocols.tcp.metadata import TcpMetadata
+if TYPE_CHECKING:
+ from pytcp.subsystems.packet_handler import PacketHandler
+
-def _phrx_tcp(self, packet_rx: PacketRx) -> None:
+def _phrx_tcp(self: PacketHandler, packet_rx: PacketRx) -> None:
"""
Handle inbound TCP packets.
"""
@@ -52,7 +57,10 @@ def _phrx_tcp(self, packet_rx: PacketRx) -> None:
if packet_rx.parse_failed:
self.packet_stats_rx.tcp__failed_parse__drop += 1
if __debug__:
- log("tcp", f"{self.tracker} - <CRIT>{packet_rx.parse_failed}</>")
+ log(
+ "tcp",
+ f"{packet_rx.tracker} - <CRIT>{packet_rx.parse_failed}</>",
+ )
return
if __debug__:

diff --git a/pytcp/protocols/tcp/phtx.py b/pytcp/protocols/tcp/phtx.py
index e37dcf1..86d622b 100755
--- a/pytcp/protocols/tcp/phtx.py
+++ b/pytcp/protocols/tcp/phtx.py
@@ -33,8 +33,10 @@
from __future__ import annotations
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, cast
+from pytcp.lib.ip4_address import Ip4Address
+from pytcp.lib.ip6_address import Ip6Address
from pytcp.lib.logger import log
from pytcp.lib.tracker import Tracker
from pytcp.misc.tx_status import TxStatus
@@ -50,10 +52,11 @@ from pytcp.protocols.tcp.fpa import (
if TYPE_CHECKING:
from pytcp.lib.ip_address import IpAddress
+ from pytcp.subsystems.packet_handler import PacketHandler
def _phtx_tcp(
- self,
+ self: PacketHandler,
*,
ip_src: IpAddress,
ip_dst: IpAddress,
@@ -156,13 +159,17 @@ def _phtx_tcp(
if ip_src.is_ip6 and ip_dst.is_ip6:
self.packet_stats_tx.tcp__send += 1
return self._phtx_ip6(
- ip6_src=ip_src, ip6_dst=ip_dst, carried_packet=tcp_packet_tx
+ ip6_src=cast(Ip6Address, ip_src),
+ ip6_dst=cast(Ip6Address, ip_dst),
+ carried_packet=tcp_packet_tx,
)
if ip_src.is_ip4 and ip_dst.is_ip4:
self.packet_stats_tx.tcp__send += 1
return self._phtx_ip4(
- ip4_src=ip_src, ip4_dst=ip_dst, carried_packet=tcp_packet_tx
+ ip4_src=cast(Ip4Address, ip_src),
+ ip4_dst=cast(Ip4Address, ip_dst),
+ carried_packet=tcp_packet_tx,
)
self.packet_stats_tx.tcp__unknown__drop += 1

diff --git a/pytcp/protocols/tcp/session.py b/pytcp/protocols/tcp/session.py
index 483b945..e4d6915 100755
--- a/pytcp/protocols/tcp/session.py
+++ b/pytcp/protocols/tcp/session.py
@@ -117,7 +117,9 @@ def trace_fsm(function: Callable) -> Callable:
Decorator for tracing FSM state.
"""
- def wrapper(self, *args: list[Any], **kwargs: dict[str, Any]) -> Any:
+ def wrapper(
+ self: TcpSession, *args: list[Any], **kwargs: dict[str, Any]
+ ) -> Any:
print(
f"[ >>> ] snd_nxt {self._snd_nxt}, snd_una {self._snd_una},",
f"rcv_nxt {self._rcv_nxt}, rcv_una {self._rcv_una}",
@@ -132,7 +134,7 @@ def trace_fsm(function: Callable) -> Callable:
return wrapper
-def trace_win(self) -> None:
+def trace_win(self: TcpSession) -> None:
"""
Method used to trace sliding window operation, invoke as 'trace_win(self)'
from within the TcpSession object.
@@ -141,6 +143,7 @@ def trace_win(self) -> None:
remaining_data_len = len(self._tx_buffer) - self._tx_buffer_nxt
usable_window = self._tx_buffer_una + self._snd_ewn - self._tx_buffer_nxt
transmit_data_len = min(self._snd_mss, usable_window, remaining_data_len)
+
print("unsent_data:", remaining_data_len)
print("usable_window:", usable_window)
print("transmit_data_len:", transmit_data_len)
@@ -405,7 +408,7 @@ class TcpSession:
"TCP session not in ESTABLISHED or CLOSE_WAIT state"
)
- def receive(self, byte_count=None) -> bytes:
+ def receive(self, byte_count: int | None = None) -> bytes:
"""
The 'RECEIVE' syscall.
"""
@@ -556,7 +559,7 @@ class TcpSession:
# If rx_buffer event has not been released yet
# (it could be released if some data were siting in buffer already)
# then release it.
- if not self._event_rx_buffer._value: # type: ignore
+ if not self._event_rx_buffer._value:
self._event_rx_buffer.release()
def _transmit_data(self) -> None:

diff --git a/pytcp/protocols/udp/phrx.py b/pytcp/protocols/udp/phrx.py
index 2ecf884..b6ee16a 100755
--- a/pytcp/protocols/udp/phrx.py
+++ b/pytcp/protocols/udp/phrx.py
@@ -33,6 +33,8 @@
from __future__ import annotations
+from typing import TYPE_CHECKING
+
import pytcp.config as config
import pytcp.misc.stack as stack
from pytcp.lib.logger import log
@@ -42,8 +44,11 @@ from pytcp.protocols.icmp6.ps import ICMP6_UNREACHABLE, ICMP6_UNREACHABLE__PORT
from pytcp.protocols.udp.fpp import UdpParser
from pytcp.protocols.udp.metadata import UdpMetadata
+if TYPE_CHECKING:
+ from pytcp.subsystems.packet_handler import PacketHandler
+
-def _phrx_udp(self, packet_rx: PacketRx) -> None:
+def _phrx_udp(self: PacketHandler, packet_rx: PacketRx) -> None:
"""
Handle inbound UDP packets.
"""
@@ -55,7 +60,10 @@ def _phrx_udp(self, packet_rx: PacketRx) -> None:
if packet_rx.parse_failed:
self.packet_stats_rx.udp__failed_parse__drop += 1
if __debug__:
- log("udp", f"{self.tracker} - <CRIT>{packet_rx.parse_failed}</>")
+ log(
+ "udp",
+ f"{packet_rx.tracker} - <CRIT>{packet_rx.parse_failed}</>",
+ )
return
if __debug__:
@@ -137,8 +145,8 @@ def _phrx_udp(self, packet_rx: PacketRx) -> None:
1
)
self._phtx_icmp6(
- ip6_src=packet_rx.ip.dst,
- ip6_dst=packet_rx.ip.src,
+ ip6_src=packet_rx.ip6.dst,
+ ip6_dst=packet_rx.ip6.src,
icmp6_type=ICMP6_UNREACHABLE,
icmp6_code=ICMP6_UNREACHABLE__PORT,
icmp6_un_data=packet_rx.ip.packet_copy,
@@ -150,8 +158,8 @@ def _phrx_udp(self, packet_rx: PacketRx) -> None:
1
)
self._phtx_icmp4(
- ip4_src=packet_rx.ip.dst,
- ip4_dst=packet_rx.ip.src,
+ ip4_src=packet_rx.ip4.dst,
+ ip4_dst=packet_rx.ip4.src,
icmp4_type=ICMP4_UNREACHABLE,
icmp4_code=ICMP4_UNREACHABLE__PORT,
icmp4_un_data=packet_rx.ip.packet_copy,

diff --git a/pytcp/protocols/udp/phtx.py b/pytcp/protocols/udp/phtx.py
index 6cdc911..7f97568 100755
--- a/pytcp/protocols/udp/phtx.py
+++ b/pytcp/protocols/udp/phtx.py
@@ -33,8 +33,10 @@
from __future__ import annotations
-from typing import TYPE_CHECKING
+from typing import TYPE_CHECKING, cast
+from pytcp.lib.ip4_address import Ip4Address
+from pytcp.lib.ip6_address import Ip6Address
from pytcp.lib.logger import log
from pytcp.lib.tracker import Tracker
from pytcp.misc.tx_status import TxStatus
@@ -42,10 +44,11 @@ from pytcp.protocols.udp.fpa import UdpAssembler
if TYPE_CHECKING:
from pytcp.lib.ip_address import IpAddress
+ from pytcp.subsystems.packet_handler import PacketHandler
def _phtx_udp(
- self,
+ self: PacketHandler,
*,
ip_src: IpAddress,
ip_dst: IpAddress,
@@ -73,13 +76,17 @@ def _phtx_udp(
if ip_src.is_ip6 and ip_dst.is_ip6:
self.packet_stats_tx.udp__send += 1
return self._phtx_ip6(
- ip6_src=ip_src, ip6_dst=ip_dst, carried_packet=udp_packet_tx
+ ip6_src=cast(Ip6Address, ip_src),
+ ip6_dst=cast(Ip6Address, ip_dst),
+ carried_packet=udp_packet_tx,
)
if ip_src.is_ip4 and ip_dst.is_ip4:
self.packet_stats_tx.udp__send += 1
return self._phtx_ip4(
- ip4_src=ip_src, ip4_dst=ip_dst, carried_packet=udp_packet_tx
+ ip4_src=cast(Ip4Address, ip_src),
+ ip4_dst=cast(Ip4Address, ip_dst),
+ carried_packet=udp_packet_tx,
)
self.packet_stats_tx.udp__unknown__drop += 1

diff --git a/pytcp/protocols/udp/socket.py b/pytcp/protocols/udp/socket.py
index 85412ac..d255fd2 100755
--- a/pytcp/protocols/udp/socket.py
+++ b/pytcp/protocols/udp/socket.py
@@ -299,7 +299,7 @@ class UdpSocket(Socket):
"[Remote host sent ICMP Unreachable]"
)
- if self._packet_rx_md_ready.acquire(timeout=timeout): # type: ignore
+ if self._packet_rx_md_ready.acquire(timeout=timeout):
data_rx = self._packet_rx_md.pop(0).data
if __debug__:
log(
@@ -319,7 +319,7 @@ class UdpSocket(Socket):
# TODO - Implement support for buffsize
- if self._packet_rx_md_ready.acquire(timeout=timeout): # type: ignore
+ if self._packet_rx_md_ready.acquire(timeout=timeout):
packet_rx_md = self._packet_rx_md.pop(0)
if __debug__:
log(

diff --git a/pytcp/subsystems/packet_handler.py b/pytcp/subsystems/packet_handler.py
index 8c1382f..35bfe73 100755
--- a/pytcp/subsystems/packet_handler.py
+++ b/pytcp/subsystems/packet_handler.py
@@ -170,7 +170,7 @@ class PacketHandler:
# Used for the ICMPv6 ND DAD process
self.ip6_unicast_candidate: Ip6Address | None = None
self.event_icmp6_nd_dad: Semaphore = threading.Semaphore(0)
- self.icmp6_nd_dad_tlla: Ip6Address | None = None
+ self.icmp6_nd_dad_tlla: MacAddress | None = None
# Used for the IcMPv6 ND RA address auto configuration
self.icmp6_ra_prefixes: list[tuple[Ip6Network, Ip6Address]] = []
@@ -181,8 +181,8 @@ class PacketHandler:
self.ip6_id: int = 0
# Used to defragment IPv4 and IPv6 packets
- self.ip4_frag_flows: dict[int, bytes] = {}
- self.ip6_frag_flows: dict[int, bytes] = {}
+ self.ip4_frag_flows: dict[tuple[Ip4Address, Ip4Address, int], dict] = {}
+ self.ip6_frag_flows: dict[tuple[Ip6Address, Ip6Address, int], dict] = {}
# Thread control
self._run_thread: bool = False
@@ -708,7 +708,9 @@ class PacketHandler:
ip6_dst=Ip6Address("ff02::16"),
ip6_hop=1,
icmp6_type=ICMP6_MLD2_REPORT,
- icmp6_mlr2_multicast_address_record=icmp6_mlr2_multicast_address_record,
+ icmp6_mlr2_multicast_address_record=list(
+ icmp6_mlr2_multicast_address_record
+ ),
)
if __debug__:
log(
@@ -903,7 +905,8 @@ class PacketHandler:
na_target_address: Ip6Address | None = None,
nd_options: list[Icmp6NdOptSLLA | Icmp6NdOptTLLA | Icmp6NdOptPI]
| None = None,
- mlr2_multicast_address_record=None,
+ mlr2_multicast_address_record: list[Icmp6MulticastAddressRecord]
+ | None = None,
) -> TxStatus:
"""
Interface method for ICMPv4 Socket -> FPA communication.
@@ -911,6 +914,7 @@ class PacketHandler:
return self._phtx_icmp6(
ip6_src=local_ip_address,
ip6_dst=remote_ip_address,
+ ip6_hop=hop,
icmp6_type=type,
icmp6_code=code,
icmp6_un_data=un_data,

diff --git a/setup.cfg b/setup.cfg
index 4a46341..18cad72 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,15 @@
[flake8]
max-line-length = 120
-ignore = E203, W503, W605
+ignore = E203, W503
[mypy]
-check_untyped_defs = no
\ No newline at end of file
+python_version = 3.10
+check_untyped_defs = True
+disallow_untyped_defs = True
+disallow_any_unimported = True
+disallow_incomplete_defs = True
+disallow_untyped_decorators = True
+no_implicit_optional = True
+warn_return_any = True
+warn_unused_ignores = True
+show_error_codes = True

diff --git a/tests/unit/arp_fpa.py b/tests/unit/arp_fpa.py
index b083848..32b9f05 100755
--- a/tests/unit/arp_fpa.py
+++ b/tests/unit/arp_fpa.py
@@ -45,14 +45,14 @@ class TestArpAssembler(TestCase):
ARP Assembler unit test class.
"""
- def test_arp_fpa__ethertype(self):
+ def test_arp_fpa__ethertype(self) -> None:
"""
Make sure the 'ArpAssembler' class has the proper
'ethertype' value assigned.
"""
self.assertEqual(ArpAssembler.ether_type, ETHER_TYPE_ARP)
- def test_arp_fpa____init__(self):
+ def test_arp_fpa____init__(self) -> None:
"""
Test the packet constructor.
"""
@@ -69,7 +69,7 @@ class TestArpAssembler(TestCase):
self.assertEqual(packet._tpa, Ip4Address("5.6.7.8"))
self.assertEqual(packet._oper, ARP_OP_REPLY)
- def test_arp_fpa____init____defaults(self):
+ def test_arp_fpa____init____defaults(self) -> None:
"""
Test the packet constructor with default arguments.
"""
@@ -80,33 +80,33 @@ class TestArpAssembler(TestCase):
self.assertEqual(packet._tpa, Ip4Address("0.0.0.0"))
self.assertEqual(packet._oper, ARP_OP_REQUEST)
- def test_arp_fpa____init____assert_oper_request(self):
+ def test_arp_fpa____init____assert_oper_request(self) -> None:
"""
Test assertion for the request operation.
"""
ArpAssembler(oper=ARP_OP_REQUEST)
- def test_arp_fpa____init____assert_oper_reply(self):
+ def test_arp_fpa____init____assert_oper_reply(self) -> None:
"""
Test assertion for the request operation.
"""
ArpAssembler(oper=ARP_OP_REPLY)
- def test_arp_fpa____init____assert_oper_unknown(self):
+ def test_arp_fpa____init____assert_oper_unknown(self) -> None:
"""
Test assertion for the unknown operation.
"""
with self.assertRaises(AssertionError):
ArpAssembler(oper=-1)
- def test_arp_fpa____len__(self):
+ def test_arp_fpa____len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
packet = ArpAssembler()
self.assertEqual(len(packet), ARP_HEADER_LEN)
- def test_arp_fpa____str____request(self):
+ def test_arp_fpa____str____request(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -123,7 +123,7 @@ class TestArpAssembler(TestCase):
"5.6.7.8 / 66:77:88:99:aa:bb",
)
- def test_arp_fpa____str____reply(self):
+ def test_arp_fpa____str____reply(self) -> None:
"""
Test the '__str__()' dudner..
"""
@@ -140,7 +140,7 @@ class TestArpAssembler(TestCase):
"5.6.7.8 / 66:77:88:99:aa:bb",
)
- def test_arp_fpa__tracker_getter(self):
+ def test_arp_fpa__tracker_getter(self) -> None:
"""
Test the '_tracker' attribute getter.
"""
@@ -149,7 +149,7 @@ class TestArpAssembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_ether_fpa__assemble(self):
+ def test_ether_fpa__assemble(self) -> None:
"""
Test the 'assemble()' method.
"""

diff --git a/tests/unit/arp_phtx.py b/tests/unit/arp_phtx.py
index 5eb52f5..9168cda 100755
--- a/tests/unit/arp_phtx.py
+++ b/tests/unit/arp_phtx.py
@@ -51,7 +51,7 @@ class TestArpPhtx(TestCase):
ARP packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Test setup.
"""
@@ -62,7 +62,7 @@ class TestArpPhtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_arp_phtx__arp_request(self):
+ def test_arp_phtx__arp_request(self) -> None:
"""
Test sending ARP request packet.
"""
@@ -90,7 +90,7 @@ class TestArpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_arp_phtx__arp_reply(self):
+ def test_arp_phtx__arp_reply(self) -> None:
"""
Test sending ARP request packet.
"""

diff --git a/tests/unit/config.py b/tests/unit/config.py
index 792e8c9..709b8a8 100755
--- a/tests/unit/config.py
+++ b/tests/unit/config.py
@@ -41,13 +41,13 @@ class TestConfig(TestCase):
Config test class.
"""
- def test_ipv6_support(self):
+ def test_ipv6_support(self) -> None:
"""
Test the 'ipv6_support' config parameter.
"""
self.assertEqual(IP6_SUPPORT, True)
- def test_ipv4_support(self):
+ def test_ipv4_support(self) -> None:
"""
Test the 'ipv4_support' config parameter.
"""

diff --git a/tests/unit/ether_fpa.py b/tests/unit/ether_fpa.py
index e855aa9..0a54598 100755
--- a/tests/unit/ether_fpa.py
+++ b/tests/unit/ether_fpa.py
@@ -48,7 +48,7 @@ class TestEtherAssembler(TestCase):
Ethernet Assembler unit test class.
"""
- def test_ether_fpa____init__(self):
+ def test_ether_fpa____init__(self) -> None:
"""
Test the packet constructor.
"""
@@ -63,7 +63,7 @@ class TestEtherAssembler(TestCase):
self.assertEqual(packet._dst, MacAddress("66:77:88:99:AA:BB"))
self.assertEqual(packet._type, ETHER_TYPE_RAW)
- def test_ether_fpa____init____defaults(self):
+ def test_ether_fpa____init____defaults(self) -> None:
"""
Test the packet constructor with default arguments.
"""
@@ -74,31 +74,31 @@ class TestEtherAssembler(TestCase):
self.assertEqual(packet._dst, MacAddress("00:00:00:00:00:00"))
self.assertEqual(packet._type, ETHER_TYPE_RAW)
- def test_ether_fpa____init____assert_ethertype_arp(self):
+ def test_ether_fpa____init____assert_ethertype_arp(self) -> None:
"""
Test assertion for carried packet 'ether_type' attribute.
"""
EtherAssembler(carried_packet=ArpAssembler())
- def test_ether_fpa____init____assert_ethertype_ip4(self):
+ def test_ether_fpa____init____assert_ethertype_ip4(self) -> None:
"""
Test assertion for carried packet 'ether_type' attribute.
"""
EtherAssembler(carried_packet=Ip4Assembler())
- def test_ether_fpa____init____assert_ethertype_ip6(self):
+ def test_ether_fpa____init____assert_ethertype_ip6(self) -> None:
"""
Test assertion for carried packet 'ether_type' attribute.
"""
EtherAssembler(carried_packet=Ip6Assembler())
- def test_ether_fpa____init____assert_ethertype_raw(self):
+ def test_ether_fpa____init____assert_ethertype_raw(self) -> None:
"""
Test assertion for carried packet 'ether_type' attribute.
"""
EtherAssembler(carried_packet=RawAssembler())
- def test_ether_fpa____init____assert_ethertype_unknown(self):
+ def test_ether_fpa____init____assert_ethertype_unknown(self) -> None:
"""
Test assertion for carried packet 'ether_type' attribute.
"""
@@ -108,7 +108,7 @@ class TestEtherAssembler(TestCase):
carried_packet_mock.tracker = StrictMock(Tracker)
EtherAssembler(carried_packet=carried_packet_mock)
- def test_ether_fpa____len__(self):
+ def test_ether_fpa____len__(self) -> None:
"""
Test the '__len__' dunder.
"""
@@ -118,7 +118,7 @@ class TestEtherAssembler(TestCase):
self.assertEqual(len(packet), ETHER_HEADER_LEN + 16)
- def test_ether_fpa____str__(self):
+ def test_ether_fpa____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -133,7 +133,7 @@ class TestEtherAssembler(TestCase):
"0xffff (raw_data), plen 30",
)
- def test_ether_fpa__tracker_getter(self):
+ def test_ether_fpa__tracker_getter(self) -> None:
"""
Test the '_tracker' attribute getter.
"""
@@ -146,7 +146,7 @@ class TestEtherAssembler(TestCase):
self.assertEqual(packet.tracker, carried_packet_mock.tracker)
- def test_ether_fpa__dst_getter(self):
+ def test_ether_fpa__dst_getter(self) -> None:
"""
Test the 'dst' attribute getter.
"""
@@ -155,7 +155,7 @@ class TestEtherAssembler(TestCase):
)
self.assertEqual(packet.dst, MacAddress("66:77:88:99:AA:BB"))
- def test_ether_fpa__dst_setter(self):
+ def test_ether_fpa__dst_setter(self) -> None:
"""
Test the 'dst' attribute setter.
"""
@@ -164,7 +164,7 @@ class TestEtherAssembler(TestCase):
)
self.assertEqual(packet.dst, MacAddress("66:77:88:99:AA:BB"))
- def test_ether_fpa__src_getter(self):
+ def test_ether_fpa__src_getter(self) -> None:
"""
Test the 'src' attribute getter.
"""
@@ -173,7 +173,7 @@ class TestEtherAssembler(TestCase):
)
self.assertEqual(packet.src, MacAddress("11:22:33:44:55:66"))
- def test_ether_fpa__src_setter(self):
+ def test_ether_fpa__src_setter(self) -> None:
"""
Test the 'src' attribute setter.
"""
@@ -182,7 +182,7 @@ class TestEtherAssembler(TestCase):
)
self.assertEqual(packet.src, MacAddress("11:22:33:44:55:66"))
- def test_ether_fpa__assemble(self):
+ def test_ether_fpa__assemble(self) -> None:
"""
Test the 'assemble()' method.
"""

diff --git a/tests/unit/ether_phtx.py b/tests/unit/ether_phtx.py
index a1e00b5..45eaf3a 100755
--- a/tests/unit/ether_phtx.py
+++ b/tests/unit/ether_phtx.py
@@ -56,7 +56,7 @@ class TestEtherPhtx(TestCase):
Ethernet packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Test setup.
"""
@@ -67,7 +67,9 @@ class TestEtherPhtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_ehter_phtx__ip4_packet_to_unicast_address_on_local_network(self):
+ def test_ehter_phtx__ip4_packet_to_unicast_address_on_local_network(
+ self,
+ ) -> None:
"""
Test sending IPv4 packet to unicast address on local network.
"""
@@ -95,7 +97,7 @@ class TestEtherPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_ether_phtx__ip4_packet_to_multicast_address(self):
+ def test_ether_phtx__ip4_packet_to_multicast_address(self) -> None:
"""
Test sending IPv4 packet to the multicast address.
"""
@@ -125,7 +127,7 @@ class TestEtherPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_ether_phtx__ip4_packet_to_limited_broadcast_address(self):
+ def test_ether_phtx__ip4_packet_to_limited_broadcast_address(self) -> None:
"""
Test sending IPv4 packet to the limited broadcast address.
"""
@@ -151,7 +153,9 @@ class TestEtherPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_ether_phtx__ip4_packet_to_local_network_broadcast_address(self):
+ def test_ether_phtx__ip4_packet_to_local_network_broadcast_address(
+ self,
+ ) -> None:
"""
Test sending IPv4 packet to the broadcast address of local network.
"""
@@ -178,7 +182,9 @@ class TestEtherPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_ether_phtx__ip4_packet_to_local_network_network_address(self):
+ def test_ether_phtx__ip4_packet_to_local_network_network_address(
+ self,
+ ) -> None:
"""
Test sending IPv4 packet to the network address of local network.
"""
@@ -313,7 +319,9 @@ class TestEtherPhtx(TestCase):
),
)
- def test_ehter_phtx__ip6_packet_to_unicast_address_on_local_network(self):
+ def test_ehter_phtx__ip6_packet_to_unicast_address_on_local_network(
+ self,
+ ) -> None:
"""
Test sending IPv6 packet to unicast address on local network.
"""
@@ -341,7 +349,7 @@ class TestEtherPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_ether_phtx__ip6_packet_to_multicast_address(self):
+ def test_ether_phtx__ip6_packet_to_multicast_address(self) -> None:
"""
Test sending IPv6 packet to the multicast address.
"""
@@ -477,7 +485,9 @@ class TestEtherPhtx(TestCase):
),
)
- def test_ether_phtx__ether_packet_with_specified_source_mac_address(self):
+ def test_ether_phtx__ether_packet_with_specified_source_mac_address(
+ self,
+ ) -> None:
"""
Send Ethernet packet with specified source MAC address.
"""
@@ -502,7 +512,9 @@ class TestEtherPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_ether_phtx__ether_packet_with_unspecified_source_mac_address(self):
+ def test_ether_phtx__ether_packet_with_unspecified_source_mac_address(
+ self,
+ ) -> None:
"""
Send Ethernet packet with unspecified source MAC address.
"""

diff --git a/tests/unit/icmp4_fpa.py b/tests/unit/icmp4_fpa.py
index 0dbafe9..f4c309d 100755
--- a/tests/unit/icmp4_fpa.py
+++ b/tests/unit/icmp4_fpa.py
@@ -52,13 +52,13 @@ class TestIcmp4Assembler(TestCase):
ICMPv4 Assembler unit test class.
"""
- def test_icmp4_fpa__ip4_proto_icmp4(self):
+ def test_icmp4_fpa__ip4_proto_icmp4(self) -> None:
"""
Make sure the 'Icmp4Assembler' class has the proper 'ip4_proto' set.
"""
self.assertEqual(Icmp4Assembler.ip4_proto, IP4_PROTO_ICMP4)
- def test_icmp4_fpa____init____echo_request(self):
+ def test_icmp4_fpa____init____echo_request(self) -> None:
"""
Test the packet constructor for the 'Echo Request' message.
"""
@@ -79,7 +79,9 @@ class TestIcmp4Assembler(TestCase):
)
)
- def test_icmp4_fpa____init____echo_request__assert_code__under(self):
+ def test_icmp4_fpa____init____echo_request__assert_code__under(
+ self,
+ ) -> None:
"""
Test packet constructor for the 'Echo Request' message.
"""
@@ -89,7 +91,7 @@ class TestIcmp4Assembler(TestCase):
code=-1,
)
- def test_icmp4_fpa____init____echo_request__assert_code__over(self):
+ def test_icmp4_fpa____init____echo_request__assert_code__over(self) -> None:
"""
Test packet constructor for the 'Echo Request' message.
"""
@@ -99,7 +101,9 @@ class TestIcmp4Assembler(TestCase):
code=1,
)
- def test_icmp4_fpa____init____echo_request__assert_ec_id__under(self):
+ def test_icmp4_fpa____init____echo_request__assert_ec_id__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -110,7 +114,9 @@ class TestIcmp4Assembler(TestCase):
ec_id=-1,
)
- def test_icmp4_fpa____init____echo_request__assert_ec_id__over(self):
+ def test_icmp4_fpa____init____echo_request__assert_ec_id__over(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -121,7 +127,9 @@ class TestIcmp4Assembler(TestCase):
ec_id=0x10000,
)
- def test_icmp4_fpa____init____echo_request__assert_ec_seq__under(self):
+ def test_icmp4_fpa____init____echo_request__assert_ec_seq__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -132,7 +140,9 @@ class TestIcmp4Assembler(TestCase):
ec_seq=-1,
)
- def test_icmp4_fpa____init____echo_request__assert_ec_seq__over(self):
+ def test_icmp4_fpa____init____echo_request__assert_ec_seq__over(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_seq' argument.
"""
@@ -143,7 +153,7 @@ class TestIcmp4Assembler(TestCase):
ec_seq=0x10000,
)
- def test_icmp4_fpa____init____unreachable_port(self):
+ def test_icmp4_fpa____init____unreachable_port(self) -> None:
"""
Test packet constructor for the 'Unreachable Port' message.
"""
@@ -160,7 +170,9 @@ class TestIcmp4Assembler(TestCase):
)
)
- def test_icmp4_fpa____init____unreachable_port__assert_code__under(self):
+ def test_icmp4_fpa____init____unreachable_port__assert_code__under(
+ self,
+ ) -> None:
"""
Test packet constructor for the 'Unreachable Port' message.
"""
@@ -170,7 +182,9 @@ class TestIcmp4Assembler(TestCase):
code=ICMP4_UNREACHABLE__PORT - 1,
)
- def test_icmp4_fpa____init____unreachable_port__assert_code__over(self):
+ def test_icmp4_fpa____init____unreachable_port__assert_code__over(
+ self,
+ ) -> None:
"""
Test packet constructor for the 'Unreachable Port' message.
"""
@@ -180,7 +194,7 @@ class TestIcmp4Assembler(TestCase):
code=ICMP4_UNREACHABLE__PORT + 1,
)
- def test_icmp4_fpa____init____echo_reply(self):
+ def test_icmp4_fpa____init____echo_reply(self) -> None:
"""
Test packet constructor for the 'Echo Reply' message.
"""
@@ -201,7 +215,7 @@ class TestIcmp4Assembler(TestCase):
)
)
- def test_icmp4_fpa____init____echo_reply__assert_code__under(self):
+ def test_icmp4_fpa____init____echo_reply__assert_code__under(self) -> None:
"""
Test packet constructor for the 'Echo Reply' message.
"""
@@ -211,7 +225,7 @@ class TestIcmp4Assembler(TestCase):
code=-1,
)
- def test_icmp4_fpa____init____echo_reply__assert_code__over(self):
+ def test_icmp4_fpa____init____echo_reply__assert_code__over(self) -> None:
"""
Test packet constructor for the 'Echo Reply' message.
"""
@@ -221,7 +235,7 @@ class TestIcmp4Assembler(TestCase):
code=1,
)
- def test_icmp4_fpa____init____echo_reply__assert_ec_id__under(self):
+ def test_icmp4_fpa____init____echo_reply__assert_ec_id__under(self) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -232,7 +246,7 @@ class TestIcmp4Assembler(TestCase):
ec_id=-1,
)
- def test_icmp4_fpa____init____echo_reply__assert_ec_id__over(self):
+ def test_icmp4_fpa____init____echo_reply__assert_ec_id__over(self) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -243,7 +257,9 @@ class TestIcmp4Assembler(TestCase):
ec_id=0x10000,
)
- def test_icmp4_fpa____init____echo_reply__assert_ec_seq__under(self):
+ def test_icmp4_fpa____init____echo_reply__assert_ec_seq__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -254,7 +270,7 @@ class TestIcmp4Assembler(TestCase):
ec_seq=-1,
)
- def test_icmp4_fpa____init____echo_reply__assert_ec_seq__over(self):
+ def test_icmp4_fpa____init____echo_reply__assert_ec_seq__over(self) -> None:
"""
Test assertion for the 'ec_seq' argument.
"""
@@ -265,7 +281,7 @@ class TestIcmp4Assembler(TestCase):
ec_seq=0x10000,
)
- def test_icmp4_fpa____init____unknown(self):
+ def test_icmp4_fpa____init____unknown(self) -> None:
"""
Test packet constructor for the message with unknown type.
"""
@@ -274,7 +290,7 @@ class TestIcmp4Assembler(TestCase):
type=255,
)
- def test_icmp4_fpa____len____echo_reply(self):
+ def test_icmp4_fpa____len____echo_reply(self) -> None:
"""
Test the '__len__()' dunder for the 'Echo Reply' message.
"""
@@ -285,7 +301,7 @@ class TestIcmp4Assembler(TestCase):
)
self.assertEqual(len(packet), ICMP4_ECHO_REPLY_LEN + 16)
- def test_icmp4_fpa____len____unreachable_port(self):
+ def test_icmp4_fpa____len____unreachable_port(self) -> None:
"""
Test the '__len__()' dunder for the 'Unreachable Port' message.
"""
@@ -296,7 +312,7 @@ class TestIcmp4Assembler(TestCase):
)
self.assertEqual(len(packet), ICMP4_UNREACHABLE_LEN + 16)
- def test_icmp4_fpa____len____echo_request(self):
+ def test_icmp4_fpa____len____echo_request(self) -> None:
"""
Test the '__len__() dudner for the 'Echo Request' message.
"""
@@ -307,7 +323,7 @@ class TestIcmp4Assembler(TestCase):
)
self.assertEqual(len(packet), ICMP4_ECHO_REQUEST_LEN + 16)
- def test_icmp4_fpa____str____echo_reply(self):
+ def test_icmp4_fpa____str____echo_reply(self) -> None:
"""
Test the '__str__()' dunder for the 'Echo Reply' message.
"""
@@ -322,7 +338,7 @@ class TestIcmp4Assembler(TestCase):
str(packet), "ICMPv4 0/0 (echo_reply), id 12345, seq 54321, dlen 16"
)
- def test_icmp4_fpa____str____unreachable_port(self):
+ def test_icmp4_fpa____str____unreachable_port(self) -> None:
"""
Test the '__str__() dunder for the 'Unreachable Port' message.
"""
@@ -333,7 +349,7 @@ class TestIcmp4Assembler(TestCase):
)
self.assertEqual(str(packet), "ICMPv4 3/3 (unreachable_port), dlen 16")
- def test_icmp4_fpa____str____echo_request(self):
+ def test_icmp4_fpa____str____echo_request(self) -> None:
"""
Test the '__str__()' dunder for the 'Echo Request' message.
"""
@@ -349,7 +365,7 @@ class TestIcmp4Assembler(TestCase):
"ICMPv4 8/0 (echo_request), id 12345, seq 54321, dlen 16",
)
- def test_icmp4_fpa__tracker_getter(self):
+ def test_icmp4_fpa__tracker_getter(self) -> None:
"""
Test the '_tracker' attribute getter.
"""
@@ -358,7 +374,7 @@ class TestIcmp4Assembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_icmp4_fpa__assemble__echo_reply(self):
+ def test_icmp4_fpa__assemble__echo_reply(self) -> None:
"""
Test the 'assemble()' method for the 'Echo Reply' message.
"""
@@ -373,7 +389,7 @@ class TestIcmp4Assembler(TestCase):
packet.assemble(frame)
self.assertEqual(bytes(frame), b"\x00\x00,\xbe09\xd410123456789ABCDEF")
- def test_icmp4_fpa__asssemble__unreachable_port(self):
+ def test_icmp4_fpa__asssemble__unreachable_port(self) -> None:
"""
Test the 'assemble()' method for the 'Unreachable Port' message.
"""
@@ -388,7 +404,7 @@ class TestIcmp4Assembler(TestCase):
bytes(frame), b"\x03\x03.&\x00\x00\x00\x000123456789ABCDEF"
)
- def test_icmp4_fpa__assemble__echo_request(self):
+ def test_icmp4_fpa__assemble__echo_request(self) -> None:
"""
Test the 'assemble()' method for the 'Echo Request' message.
"""

diff --git a/tests/unit/icmp4_phtx.py b/tests/unit/icmp4_phtx.py
index 819bbb8..ec164aa 100755
--- a/tests/unit/icmp4_phtx.py
+++ b/tests/unit/icmp4_phtx.py
@@ -56,7 +56,7 @@ class TestIcmp4Phtx(TestCase):
ICMPv4 packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Test setup.
"""
@@ -67,7 +67,7 @@ class TestIcmp4Phtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_icmp4_phtx__ip4_icmp4_echo_request(self):
+ def test_icmp4_phtx__ip4_icmp4_echo_request(self) -> None:
"""
Test sending the IPv4/ICMPv4 'Echo Request' packet.
"""
@@ -98,7 +98,7 @@ class TestIcmp4Phtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_icmp4_phtx__ip4_icmp4_echo_reply(self):
+ def test_icmp4_phtx__ip4_icmp4_echo_reply(self) -> None:
"""
Test sending the IPv4/ICMPv4 'Echo Reply' packet.
"""
@@ -128,7 +128,7 @@ class TestIcmp4Phtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_icmp4_phtx__ip4_icmp4_unreachable_port(self):
+ def test_icmp4_phtx__ip4_icmp4_unreachable_port(self) -> None:
"""
Test sending the IPv4/ICMPv4 'Unreachable Port' packet.
"""

diff --git a/tests/unit/icmp6_fpa.py b/tests/unit/icmp6_fpa.py
index 49ab3ef..43267ff 100755
--- a/tests/unit/icmp6_fpa.py
+++ b/tests/unit/icmp6_fpa.py
@@ -73,13 +73,13 @@ class TestIcmp6Assembler(TestCase):
ICMPv6 protocol packet assembler unit test class.
"""
- def test_icmp6_fpa__ip6_next_icmp6(self):
+ def test_icmp6_fpa__ip6_next_icmp6(self) -> None:
"""
Make sure the 'Icmp6Assembler' class has the proper 'ip6_next' set.
"""
self.assertEqual(Icmp6Assembler.ip6_next, IP6_NEXT_ICMP6)
- def test_icmp6_fpa____init____unreachable_port(self):
+ def test_icmp6_fpa____init____unreachable_port(self) -> None:
"""
Test packet constructor for the 'Unreachable Port' message.
"""
@@ -96,7 +96,9 @@ class TestIcmp6Assembler(TestCase):
)
)
- def test_icmp6_fpa____init____unreachable_port__assert_code__under(self):
+ def test_icmp6_fpa____init____unreachable_port__assert_code__under(
+ self,
+ ) -> None:
"""
Test packet constructor for the 'Unreachable Port' message.
"""
@@ -106,7 +108,9 @@ class TestIcmp6Assembler(TestCase):
code=ICMP6_UNREACHABLE__PORT - 1,
)
- def test_icmp6_fpa____init____unreachable_port__assert_code__over(self):
+ def test_icmp6_fpa____init____unreachable_port__assert_code__over(
+ self,
+ ) -> None:
"""
Test packet constructor for the 'Unreachable Port' message.
"""
@@ -116,7 +120,7 @@ class TestIcmp6Assembler(TestCase):
code=ICMP6_UNREACHABLE__PORT + 1,
)
- def test_icmp6_fpa____init____echo_request(self):
+ def test_icmp6_fpa____init____echo_request(self) -> None:
"""
Test packet constructor for the 'Echo Request' message.
"""
@@ -137,7 +141,9 @@ class TestIcmp6Assembler(TestCase):
)
)
- def test_icmp6_fpa____init____echo_request__assert_code__under(self):
+ def test_icmp6_fpa____init____echo_request__assert_code__under(
+ self,
+ ) -> None:
"""
Test packet constructor for the 'Echo Request' message.
"""
@@ -147,7 +153,7 @@ class TestIcmp6Assembler(TestCase):
code=-1,
)
- def test_icmp6_fpa____init____echo_request__assert_code__over(self):
+ def test_icmp6_fpa____init____echo_request__assert_code__over(self) -> None:
"""
Test class constructor for the 'Echo Request' message.
"""
@@ -157,7 +163,9 @@ class TestIcmp6Assembler(TestCase):
code=1,
)
- def test_icmp6_fpa____init____echo_request__assert_ec_id__under(self):
+ def test_icmp6_fpa____init____echo_request__assert_ec_id__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -168,7 +176,9 @@ class TestIcmp6Assembler(TestCase):
ec_id=-1,
)
- def test_icmp6_fpa____init____echo_request__assert_ec_id__over(self):
+ def test_icmp6_fpa____init____echo_request__assert_ec_id__over(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -179,7 +189,9 @@ class TestIcmp6Assembler(TestCase):
ec_id=0x10000,
)
- def test_icmp6_fpa____init____echo_request__assert_ec_seq__under(self):
+ def test_icmp6_fpa____init____echo_request__assert_ec_seq__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -190,7 +202,9 @@ class TestIcmp6Assembler(TestCase):
ec_seq=-1,
)
- def test_icmp6_fpa____init____echo_request__assert_ec_seq__over(self):
+ def test_icmp6_fpa____init____echo_request__assert_ec_seq__over(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_seq' argument.
"""
@@ -201,7 +215,7 @@ class TestIcmp6Assembler(TestCase):
ec_seq=0x10000,
)
- def test_icmp6_fpa____init____echo_reply(self):
+ def test_icmp6_fpa____init____echo_reply(self) -> None:
"""
Test packet constructor for the 'Echo Reply' message.
"""
@@ -224,7 +238,7 @@ class TestIcmp6Assembler(TestCase):
)
)
- def test_icmp6_fpa____init____echo_reply__assert_code__under(self):
+ def test_icmp6_fpa____init____echo_reply__assert_code__under(self) -> None:
"""
Test packet constructor for the 'Echo Reply' message.
"""
@@ -234,7 +248,7 @@ class TestIcmp6Assembler(TestCase):
code=-1,
)
- def test_icmp6_fpa____init____echo_reply__assert_code__over(self):
+ def test_icmp6_fpa____init____echo_reply__assert_code__over(self) -> None:
"""
Test packet constructor for the 'Echo Reply' message.
"""
@@ -244,7 +258,7 @@ class TestIcmp6Assembler(TestCase):
code=1,
)
- def test_icmp6_fpa____init____echo_reply__assert_ec_id__under(self):
+ def test_icmp6_fpa____init____echo_reply__assert_ec_id__under(self) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -255,7 +269,7 @@ class TestIcmp6Assembler(TestCase):
ec_id=-1,
)
- def test_icmp6_fpa____init____echo_reply__assert_ec_id__over(self):
+ def test_icmp6_fpa____init____echo_reply__assert_ec_id__over(self) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -266,7 +280,9 @@ class TestIcmp6Assembler(TestCase):
ec_id=0x10000,
)
- def test_icmp6_fpa____init____echo_reply__assert_ec_seq__under(self):
+ def test_icmp6_fpa____init____echo_reply__assert_ec_seq__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'ec_id' argument.
"""
@@ -277,7 +293,7 @@ class TestIcmp6Assembler(TestCase):
ec_seq=-1,
)
- def test_icmp6_fpa____init____echo_reply__assert_ec_seq__over(self):
+ def test_icmp6_fpa____init____echo_reply__assert_ec_seq__over(self) -> None:
"""
Test assertion for the 'ec_seq' argument.
"""
@@ -288,7 +304,7 @@ class TestIcmp6Assembler(TestCase):
ec_seq=0x10000,
)
- def test_icmp6_fpa____init____unknown(self):
+ def test_icmp6_fpa____init____unknown(self) -> None:
"""
Test packet constructor for message with unknown type.
"""
@@ -297,7 +313,7 @@ class TestIcmp6Assembler(TestCase):
type=255,
)
- def test_icmp6_fpa____init____nd_router_solicitation(self):
+ def test_icmp6_fpa____init____nd_router_solicitation(self) -> None:
"""
Test packet constructor for the 'ND Router Solicitation' message.
"""
@@ -348,7 +364,7 @@ class TestIcmp6Assembler(TestCase):
code=1,
)
- def test_icmp6_fpa____init____nd_router_advertisement(self):
+ def test_icmp6_fpa____init____nd_router_advertisement(self) -> None:
"""
Test packet constructor for the 'ND Router Advertisement' message.
"""
@@ -506,7 +522,7 @@ class TestIcmp6Assembler(TestCase):
ra_retrans_timer=0x100000000,
)
- def test_icmp6_fpa____init____nd_neighbor_solicitation(self):
+ def test_icmp6_fpa____init____nd_neighbor_solicitation(self) -> None:
"""
Test packet constructor for the 'ND Neighbor Solicitation' message.
"""
@@ -560,7 +576,7 @@ class TestIcmp6Assembler(TestCase):
code=1,
)
- def test_icmp6_fpa____init____nd_neighbor_advertisement(self):
+ def test_icmp6_fpa____init____nd_neighbor_advertisement(self) -> None:
"""
Test packet constructor for the 'ND Neighbor Advertisement' message.
"""
@@ -621,7 +637,7 @@ class TestIcmp6Assembler(TestCase):
code=1,
)
- def test_icmp6_fpa____init____mld2_report(self):
+ def test_icmp6_fpa____init____mld2_report(self) -> None:
"""
Test packet constructor for the 'Multicast Discovery v2 Report' message.
"""
@@ -657,7 +673,7 @@ class TestIcmp6Assembler(TestCase):
)
)
- def test_icmp6_fpa____init____mld2_record__assert_code__under(self):
+ def test_icmp6_fpa____init____mld2_record__assert_code__under(self) -> None:
"""
Test packet constructor for the 'Multicast Discovery v2 Report' message.
"""
@@ -667,7 +683,7 @@ class TestIcmp6Assembler(TestCase):
code=-1,
)
- def test_icmp6_fpa____init____mld2_record__assert_code__over(self):
+ def test_icmp6_fpa____init____mld2_record__assert_code__over(self) -> None:
"""
Test class constructor for the 'Multicast Discovery v2 Report' message.
"""
@@ -677,7 +693,7 @@ class TestIcmp6Assembler(TestCase):
code=1,
)
- def test_icmp6_fpa____len____unreachable_port(self):
+ def test_icmp6_fpa____len____unreachable_port(self) -> None:
"""
Test the '__len__()' dunder for 'Unreachable Port' message.
"""
@@ -689,7 +705,7 @@ class TestIcmp6Assembler(TestCase):
self.assertEqual(len(packet), ICMP6_UNREACHABLE_LEN + 16)
- def test_icmp6_fpa____len____echo_request(self):
+ def test_icmp6_fpa____len____echo_request(self) -> None:
"""
Test the '__len__()' dunder for 'Unreachable Port' message.
"""
@@ -701,7 +717,7 @@ class TestIcmp6Assembler(TestCase):
self.assertEqual(len(packet), ICMP6_ECHO_REQUEST_LEN + 16)
- def test_icmp6_fpa____len____echo_reply(self):
+ def test_icmp6_fpa____len____echo_reply(self) -> None:
"""
Test the '__len__()' dunder for 'Echo Reply' message.
"""
@@ -713,7 +729,7 @@ class TestIcmp6Assembler(TestCase):
self.assertEqual(len(packet), ICMP6_ECHO_REPLY_LEN + 16)
- def test_icmp6_fpa____len____nd_router_solicitation(self):
+ def test_icmp6_fpa____len____nd_router_solicitation(self) -> None:
"""
Test the '__len__()' dunder for 'Router Solicitation' message.
"""
@@ -732,7 +748,7 @@ class TestIcmp6Assembler(TestCase):
+ ICMP6_ND_OPT_TLLA_LEN,
)
- def test_icmp6_fpa____len____nd_router_advertisement(self):
+ def test_icmp6_fpa____len____nd_router_advertisement(self) -> None:
"""
Test the '__len__() dunder for 'Router Advertisement' message.
"""
@@ -758,7 +774,7 @@ class TestIcmp6Assembler(TestCase):
+ ICMP6_ND_OPT_TLLA_LEN,
)
- def test_icmp6_fpa____len____nd_neighbor_solicitation(self):
+ def test_icmp6_fpa____len____nd_neighbor_solicitation(self) -> None:
"""
Test the '__len__() dunder for 'Neighbor Solicitation' message.
"""
@@ -778,7 +794,7 @@ class TestIcmp6Assembler(TestCase):
+ ICMP6_ND_OPT_TLLA_LEN,
)
- def test_icmp6_fpa____len____nd_neighbor_advertisement(self):
+ def test_icmp6_fpa____len____nd_neighbor_advertisement(self) -> None:
"""
Test the '__len__()' dunder for 'Neighbor Advertisement' message.
"""
@@ -802,7 +818,7 @@ class TestIcmp6Assembler(TestCase):
+ ICMP6_ND_OPT_TLLA_LEN,
)
- def test_icmp6_fpa____str____unreachable_port(self):
+ def test_icmp6_fpa____str____unreachable_port(self) -> None:
"""
Test the '__str__()' dunder for 'Unreachable Port' message.
"""
@@ -813,7 +829,7 @@ class TestIcmp6Assembler(TestCase):
)
self.assertEqual(str(packet), "ICMPv6 1/4 (unreachable_port), dlen 16")
- def test_icmp6_fpa____str____echo_request(self):
+ def test_icmp6_fpa____str____echo_request(self) -> None:
"""
Test the '__str__() dunder for 'Echo Request' message.
"""
@@ -829,7 +845,7 @@ class TestIcmp6Assembler(TestCase):
"ICMPv6 128/0 (echo_request), id 12345, seq 54321, dlen 16",
)
- def test_icmp6_fpa____str____echo_reply(self):
+ def test_icmp6_fpa____str____echo_reply(self) -> None:
"""
Test the '__str__()'dunder for 'Echo Reply' message.
"""
@@ -845,7 +861,7 @@ class TestIcmp6Assembler(TestCase):
"ICMPv6 129/0 (echo_reply), id 12345, seq 54321, dlen 16",
)
- def test_icmp6_fpa____str____nd_router_solicitation(self):
+ def test_icmp6_fpa____str____nd_router_solicitation(self) -> None:
"""
Test the '__str__()' dunder for 'Router Solicitation' message.
"""
@@ -863,7 +879,9 @@ class TestIcmp6Assembler(TestCase):
"tlla 66:55:44:33:22:11",
)
- def test_icmp6_fpa____str____nd_router_solicitation__no_options(self):
+ def test_icmp6_fpa____str____nd_router_solicitation__no_options(
+ self,
+ ) -> None:
"""
Test the '__str__()' dunder for 'Router Solicitation' message.
"""
@@ -873,7 +891,7 @@ class TestIcmp6Assembler(TestCase):
)
self.assertEqual(str(packet), "ICMPv6 133/0 (nd_router_solicitation)")
- def test_icmp6_fpa____str____nd_router_advertisement(self):
+ def test_icmp6_fpa____str____nd_router_advertisement(self) -> None:
"""
Test the '__str__()' dunder for the 'Router Advertisement' message.
"""
@@ -899,7 +917,9 @@ class TestIcmp6Assembler(TestCase):
"slla 11:22:33:44:55:66, tlla 66:55:44:33:22:11",
)
- def test_icmp6_fpa____str____nd_router_advertisement__no_options(self):
+ def test_icmp6_fpa____str____nd_router_advertisement__no_options(
+ self,
+ ) -> None:
"""
Test the '__str__ ()' dunder for 'Router Advertisement' message.
"""
@@ -920,7 +940,7 @@ class TestIcmp6Assembler(TestCase):
"rlft 12345, reacht 12345678, retrt 87654321",
)
- def test_icmp6_fpa____str____nd_neighbor_solicitation(self):
+ def test_icmp6_fpa____str____nd_neighbor_solicitation(self) -> None:
"""
Test the '__str__()' dunder for 'Neighbor Solicitation' message.
"""
@@ -939,7 +959,9 @@ class TestIcmp6Assembler(TestCase):
"slla 11:22:33:44:55:66, tlla 66:55:44:33:22:11",
)
- def test_icmp6_fpa____str____nd_neighbor_solicitation__no_options(self):
+ def test_icmp6_fpa____str____nd_neighbor_solicitation__no_options(
+ self,
+ ) -> None:
"""
Test the '__str__()' dunder for 'Neighbor Solicitation' message.
"""
@@ -953,7 +975,7 @@ class TestIcmp6Assembler(TestCase):
"ICMPv6 135/0 (nd_neighbor_solicitation), target 1:2:3:4:5:6:7:8",
)
- def test_icmp6_fpa____str____nd_neighbor_advertisement(self):
+ def test_icmp6_fpa____str____nd_neighbor_advertisement(self) -> None:
"""
Test '__str__()' dunder for 'Neighbor Advertisement' message.
"""
@@ -976,7 +998,9 @@ class TestIcmp6Assembler(TestCase):
"flags RSO, slla 11:22:33:44:55:66, tlla 66:55:44:33:22:11",
)
- def test_icmp6_fpa____str____nd_neighbor_advertisement__no_options(self):
+ def test_icmp6_fpa____str____nd_neighbor_advertisement__no_options(
+ self,
+ ) -> None:
"""
Test the '__str__()' dunder for 'Neighbor Advertisement' message.
"""
@@ -995,7 +1019,7 @@ class TestIcmp6Assembler(TestCase):
"flags RSO",
)
- def test_icmp6_fpa__tracker_getter(self):
+ def test_icmp6_fpa__tracker_getter(self) -> None:
"""
Test the '_tracker' attribute getter.
"""
@@ -1004,7 +1028,7 @@ class TestIcmp6Assembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_icmp6_fpa__asssemble__unreachable_port(self):
+ def test_icmp6_fpa__asssemble__unreachable_port(self) -> None:
"""
Test the 'assemble()' method for 'Unreachable Port' message.
"""
@@ -1019,7 +1043,7 @@ class TestIcmp6Assembler(TestCase):
bytes(frame), b"\x01\x04Y\x8b\x00\x00\x00\x000123456789ABCDEF"
)
- def test_icmp6_fpa__assemble__echo_request(self):
+ def test_icmp6_fpa__assemble__echo_request(self) -> None:
"""
Test the 'assemble()' method for 'Echo Request' message.
"""
@@ -1034,7 +1058,7 @@ class TestIcmp6Assembler(TestCase):
packet.assemble(frame, 12345678)
self.assertEqual(bytes(frame), b"\x80\x00J\xb309\xd410123456789ABCDEF")
- def test_icmp6_fpa__assemble__echo_reply(self):
+ def test_icmp6_fpa__assemble__echo_reply(self) -> None:
"""
Test the 'assemble() method for 'Echo Reply' message..
"""
@@ -1049,7 +1073,7 @@ class TestIcmp6Assembler(TestCase):
packet.assemble(frame, 12345678)
self.assertEqual(bytes(frame), b"\x81\x00I\xb309\xd410123456789ABCDEF")
- def test_icmp6_fpa__assemble__nd_router_solicitation(self):
+ def test_icmp6_fpa__assemble__nd_router_solicitation(self) -> None:
"""
Test the 'assemble()' method for 'Router Solicitation' message.
"""
@@ -1069,7 +1093,7 @@ class TestIcmp6Assembler(TestCase):
b'\x11"3DUf\x02\x01fUD3"\x11',
)
- def test_icmp6_fpa__assemble__nd_router_advertisement(self):
+ def test_icmp6_fpa__assemble__nd_router_advertisement(self) -> None:
"""
Test 'assemble()' method for 'Router Advertisement' message.
"""
@@ -1096,7 +1120,7 @@ class TestIcmp6Assembler(TestCase):
b'\x11"3DUf\x02\x01fUD3"\x11',
)
- def test_icmp6_fpa__assemble__nd_neighbor_solicitation(self):
+ def test_icmp6_fpa__assemble__nd_neighbor_solicitation(self) -> None:
"""
Test the 'assemble() method for 'Neighbor Solicitation' message.
"""
@@ -1117,7 +1141,7 @@ class TestIcmp6Assembler(TestCase):
b'\x00\x05\x00\x06\x00\x07\x00\x08\x01\x01\x11"3DUf\x02\x01fUD3"\x11',
)
- def test_icmp6_fpa__assemble__nd_neighbor_advertisement(self):
+ def test_icmp6_fpa__assemble__nd_neighbor_advertisement(self) -> None:
"""
Test the 'assemble()' method for 'Neighbor Advertisement' message.
"""
@@ -1149,35 +1173,35 @@ class TestIcmp6NdOptSLLA(TestCase):
ICMPv6 ND SLLA Option unit test class.
"""
- def test_icmp6_fpa_nd_opt_slla____init__(self):
+ def test_icmp6_fpa_nd_opt_slla____init__(self) -> None:
"""
Test the option constructor.
"""
option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
self.assertEqual(option._slla, MacAddress("11:22:33:44:55:66"))
- def test_icmp6_fpa_nd_opt_slla____str__(self):
+ def test_icmp6_fpa_nd_opt_slla____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
self.assertEqual(str(option), "slla 11:22:33:44:55:66")
- def test_icmp6_fpa_nd_opt_slla____repr__(self):
+ def test_icmp6_fpa_nd_opt_slla____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
self.assertEqual(repr(option), f"Icmp6NdOptSLLA({repr(option._slla)})")
- def test_icmp6_fpa_nd_opt_slla____bytes__(self):
+ def test_icmp6_fpa_nd_opt_slla____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = Icmp6NdOptSLLA(MacAddress("11:22:33:44:55:66"))
self.assertEqual(bytes(option), b'\x01\x01\x11"3DUf')
- def test_icmp6_fpa_nd_opt_slla____eq__(self):
+ def test_icmp6_fpa_nd_opt_slla____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -1192,35 +1216,35 @@ class TestIcmp6NdOptTLLA(TestCase):
ICMPv6 ND TLLA Option unit test class.
"""
- def test_icmp6_fpa_nd_opt_tlla____init__(self):
+ def test_icmp6_fpa_nd_opt_tlla____init__(self) -> None:
"""
Test the option constructor.
"""
option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
self.assertEqual(option._tlla, MacAddress("66:55:44:33:22:11"))
- def test_icmp6_fpa_nd_opt_tlla____str__(self):
+ def test_icmp6_fpa_nd_opt_tlla____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
self.assertEqual(str(option), "tlla 66:55:44:33:22:11")
- def test_icmp6_fpa_nd_opt_tlla____repr__(self):
+ def test_icmp6_fpa_nd_opt_tlla____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
self.assertEqual(repr(option), f"Icmp6NdOptTLLA({repr(option._tlla)})")
- def test_icmp6_fpa_nd_opt_tlla____bytes__(self):
+ def test_icmp6_fpa_nd_opt_tlla____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = Icmp6NdOptTLLA(MacAddress("66:55:44:33:22:11"))
self.assertEqual(bytes(option), b'\x02\x01fUD3"\x11')
- def test_icmp6_fpa_nd_opt_tlla____eq__(self):
+ def test_icmp6_fpa_nd_opt_tlla____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -1235,7 +1259,7 @@ class TestIcmp6NdOptPI(TestCase):
ICMPv6 ND PI Option unit test class.
"""
- def test_icmp6_fpa_nd_opt_pi____init__(self):
+ def test_icmp6_fpa_nd_opt_pi____init__(self) -> None:
"""
Test the option constructor.
"""
@@ -1254,7 +1278,9 @@ class TestIcmp6NdOptPI(TestCase):
self.assertEqual(option._flag_a, True)
self.assertEqual(option._flag_r, True)
- def test_icmp6_fpa_nd_opt_pi____init____assert_valid_lifetime__under(self):
+ def test_icmp6_fpa_nd_opt_pi____init____assert_valid_lifetime__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'valid_lifetime' argument.
"""
@@ -1265,7 +1291,9 @@ class TestIcmp6NdOptPI(TestCase):
prefix=Ip6Network("1:2:3:4::/64"),
)
- def test_icmp6_fpa_nd_opt_pi____init____assert_valid_lifetime__over(self):
+ def test_icmp6_fpa_nd_opt_pi____init____assert_valid_lifetime__over(
+ self,
+ ) -> None:
"""
Test assertion for the 'valid_lifetime' argument.
"""
@@ -1276,7 +1304,9 @@ class TestIcmp6NdOptPI(TestCase):
prefix=Ip6Network("1:2:3:4::/64"),
)
- def test_icmp6_fpa_nd_opt_pi____init____assert_prefer_lifetime__under(self):
+ def test_icmp6_fpa_nd_opt_pi____init____assert_prefer_lifetime__under(
+ self,
+ ) -> None:
"""
Test assertion for the 'prefer_lifetime' argument.
"""
@@ -1287,7 +1317,9 @@ class TestIcmp6NdOptPI(TestCase):
prefix=Ip6Network("1:2:3:4::/64"),
)
- def test_icmp6_fpa_nd_opt_pi____init____assert_prefer_lifetime__over(self):
+ def test_icmp6_fpa_nd_opt_pi____init____assert_prefer_lifetime__over(
+ self,
+ ) -> None:
"""
Test assertion for the 'prefer_lifetime' argument.
"""
@@ -1298,7 +1330,7 @@ class TestIcmp6NdOptPI(TestCase):
prefix=Ip6Network("1:2:3:4::/64"),
)
- def test_icmp6_fpa_nd_opt_pi____str__(self):
+ def test_icmp6_fpa_nd_opt_pi____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -1316,7 +1348,7 @@ class TestIcmp6NdOptPI(TestCase):
"flags LAR",
)
- def test_icmp6_fpa_nd_opt_pi____repr__(self):
+ def test_icmp6_fpa_nd_opt_pi____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -1335,7 +1367,7 @@ class TestIcmp6NdOptPI(TestCase):
"flag_r=True)",
)
- def test_icmp6_fpa_nd_opt_pi____bytes__(self):
+ def test_icmp6_fpa_nd_opt_pi____bytes__(self) -> None:
"""
Test the '__bytes__() dunder.
"""
@@ -1353,7 +1385,7 @@ class TestIcmp6NdOptPI(TestCase):
b"\x02\x00\x03\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00",
)
- def test_icmp6_fpa_nd_opt_pi____eq__(self):
+ def test_icmp6_fpa_nd_opt_pi____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""

diff --git a/tests/unit/icmp6_phtx.py b/tests/unit/icmp6_phtx.py
index 5bec605..730f68d 100755
--- a/tests/unit/icmp6_phtx.py
+++ b/tests/unit/icmp6_phtx.py
@@ -58,7 +58,7 @@ class TestIcmp6Phtx(TestCase):
ICMPv6 packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Setup tests.
"""
@@ -69,7 +69,7 @@ class TestIcmp6Phtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_icmp6_phtx__ip6_icmp6_echo_request(self):
+ def test_icmp6_phtx__ip6_icmp6_echo_request(self) -> None:
"""
Test sending the IPv6/ICMPv6 'Echo Request' packet.
"""
@@ -99,7 +99,7 @@ class TestIcmp6Phtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_icmp6_phtx__ip6_icmp6_echo_reply(self):
+ def test_icmp6_phtx__ip6_icmp6_echo_reply(self) -> None:
"""
Test sending the IPv6/ICMPv6 'Echo Reply' packet.
"""
@@ -130,7 +130,7 @@ class TestIcmp6Phtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_icmp6_phtx__ip6_icmp6_unreachable_port(self):
+ def test_icmp6_phtx__ip6_icmp6_unreachable_port(self) -> None:
"""
Test sending the IPv6/ICMPv6 'Unreachable Port' packet.
"""
@@ -159,7 +159,7 @@ class TestIcmp6Phtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_icmp6_phtx__ip6_icmp6_nd_router_solicitation(self):
+ def test_icmp6_phtx__ip6_icmp6_nd_router_solicitation(self) -> None:
"""
Test sending the IPv6/ICMPv6 'ND Router Solicitation' packet.
"""

diff --git a/tests/unit/ip4_address.py b/tests/unit/ip4_address.py
index f4ae58c..2138ff1 100755
--- a/tests/unit/ip4_address.py
+++ b/tests/unit/ip4_address.py
@@ -53,7 +53,7 @@ class TestIp4Address(TestCase):
Unit tests for the 'Ip4Address' class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Setup tests.
"""
@@ -251,7 +251,7 @@ class TestIp4Address(TestCase):
),
]
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the 'Ip4Address' object constructor.
"""
@@ -310,13 +310,13 @@ class TestIp4Address(TestCase):
4294967296,
)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
self.assertEqual(str(Ip4Address("192.168.9.1")), "192.168.9.1")
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -324,25 +324,25 @@ class TestIp4Address(TestCase):
repr(Ip4Address("192.168.9.1")), "Ip4Address('192.168.9.1')"
)
- def test___bytes__(self):
+ def test___bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
self.assertEqual(bytes(Ip4Address("192.168.9.1")), b"\xc0\xa8\t\x01")
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
self.assertEqual(Ip4Address("192.168.9.1"), Ip4Address("192.168.9.1"))
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dunder.
"""
self.assertEqual(hash(Ip4Address("192.168.9.1")), hash(3232237825))
- def test___contains__(self):
+ def test___contains__(self) -> None:
"""
Test the '__contains__()' dunder.
"""
@@ -350,27 +350,27 @@ class TestIp4Address(TestCase):
self.assertNotIn(Ip4Address("192.168.9.7"), Ip4Network("172.16.0.0/12"))
self.assertNotIn(Ip4Address("192.168.9.7"), Ip4Network("10.0.0.0/8"))
- def test_version(self):
+ def test_version(self) -> None:
"""
Test the 'version' property.
"""
self.assertEqual(Ip4Address("192.168.9.1").version, 4)
- def test_is_invalid(self):
+ def test_is_invalid(self) -> None:
"""
Test the 'is_invalid' property.
"""
for sample in self.ip4_samples:
self.assertEqual(sample.ip4_address.is_invalid, sample.is_invalid)
- def test_is_global(self):
+ def test_is_global(self) -> None:
"""
Test the 'is_global' property.
"""
for sample in self.ip4_samples:
self.assertEqual(sample.ip4_address.is_global, sample.is_global)
- def test_is_link_local(self):
+ def test_is_link_local(self) -> None:
"""
Test the 'is_link_local' property.
"""
@@ -379,14 +379,14 @@ class TestIp4Address(TestCase):
sample.ip4_address.is_link_local, sample.is_link_local
)
- def test_is_loopback(self):
+ def test_is_loopback(self) -> None:
"""
Test the 'is_loopback' property.
"""
for sample in self.ip4_samples:
self.assertEqual(sample.ip4_address.is_loopback, sample.is_loopback)
- def test_is_multicast(self):
+ def test_is_multicast(self) -> None:
"""
Test the 'is_multicast' property.
"""
@@ -395,14 +395,14 @@ class TestIp4Address(TestCase):
sample.ip4_address.is_multicast, sample.is_multicast
)
- def test_is_private(self):
+ def test_is_private(self) -> None:
"""
Test the 'is_private' property.
"""
for sample in self.ip4_samples:
self.assertEqual(sample.ip4_address.is_private, sample.is_private)
- def test_is_unspecified(self):
+ def test_is_unspecified(self) -> None:
"""
Test the 'is_unspecified' property.
"""
@@ -411,7 +411,7 @@ class TestIp4Address(TestCase):
sample.ip4_address.is_unspecified, sample.is_unspecified
)
- def test_is_limited_broadcast(self):
+ def test_is_limited_broadcast(self) -> None:
"""
Test 'is_limited_broadcast' property.
"""
@@ -421,14 +421,14 @@ class TestIp4Address(TestCase):
sample.is_limited_broadcast,
)
- def test_is_unicast(self):
+ def test_is_unicast(self) -> None:
"""
Test 'is_unicast' property.
"""
for sample in self.ip4_samples:
self.assertEqual(sample.ip4_address.is_unicast, sample.is_unicast)
- def test_unspecified(self):
+ def test_unspecified(self) -> None:
"""
Test 'unspecified' property.
"""
@@ -436,7 +436,7 @@ class TestIp4Address(TestCase):
Ip4Address("192.168.9.1").unspecified, Ip4Address("0.0.0.0")
)
- def test_multicast_mac(self):
+ def test_multicast_mac(self) -> None:
"""
Test 'multicast_mac' property.
"""
@@ -451,7 +451,7 @@ class TestIp4Mask(TestCase):
Unit tests for the 'Ip4Mask' class.
"""
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the 'Ip4Mask' object constructor.
"""
@@ -539,51 +539,51 @@ class TestIp4Mask(TestCase):
8,
)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
self.assertEqual(str(Ip4Mask("255.255.240.0")), "/20")
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
self.assertEqual(repr(Ip4Mask("/12")), "Ip4Mask('/12')")
- def test___bytes__(self):
+ def test___bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
self.assertEqual(bytes(Ip4Mask("255.255.0.0")), b"\xff\xff\x00\x00")
- def test___int__(self):
+ def test___int__(self) -> None:
"""
Test the '__int__()' dunder.
"""
self.assertEqual(int(Ip4Mask("255.255.192.0")), 4294950912)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
self.assertEqual(Ip4Mask("255.255.255.240"), Ip4Mask("/28"))
self.assertNotEqual(Ip4Mask("255.255.255.240"), Ip4Mask("/29"))
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dunder.
"""
self.assertEqual(hash(Ip4Mask("/32")), hash(4294967295))
- def test___len__(self):
+ def test___len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
for n in range(33):
self.assertEqual(len(Ip4Mask(f"/{n}")), n)
- def test_version(self):
+ def test_version(self) -> None:
"""
Test the 'version' property.
"""
@@ -595,7 +595,7 @@ class TestIp4Network(TestCase):
Unit tests for the 'Ip4Network' class.
"""
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the 'Ip4Network' object constructor.
"""
@@ -659,13 +659,13 @@ class TestIp4Network(TestCase):
"192.168.9.0",
)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
self.assertEqual(str(Ip4Network("192.168.9.0/24")), "192.168.9.0/24")
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -673,14 +673,14 @@ class TestIp4Network(TestCase):
repr(Ip4Network("172.16.0.0/12")), "Ip4Network('172.16.0.0/12')"
)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
self.assertEqual(Ip4Network("0.0.0.0/0"), Ip4Network("0.0.0.0/0"))
self.assertNotEqual(Ip4Network("0.0.0.0/0"), Ip4Network("0.0.0.0/32"))
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dinder.
"""
@@ -689,7 +689,7 @@ class TestIp4Network(TestCase):
hash(Ip4Address("10.0.0.0")) ^ hash(Ip4Mask("255.0.0.0")),
)
- def test_address(self):
+ def test_address(self) -> None:
"""
Test the 'address' property.
"""
@@ -697,7 +697,7 @@ class TestIp4Network(TestCase):
Ip4Network("192.168.9.100/24").address, Ip4Address("192.168.9.0")
)
- def test_mask(self):
+ def test_mask(self) -> None:
"""
Test the 'mask' property.
"""
@@ -705,7 +705,7 @@ class TestIp4Network(TestCase):
Ip4Network("192.168.9.0/24").mask, Ip4Mask("255.255.255.0")
)
- def test_broadcast(self):
+ def test_broadcast(self) -> None:
"""
Test the 'broadcast' property.
"""
@@ -714,7 +714,7 @@ class TestIp4Network(TestCase):
Ip4Address("192.168.9.255"),
)
- def test_version(self):
+ def test_version(self) -> None:
"""
Test the 'version' property.
"""
@@ -726,7 +726,7 @@ class TestIp4Host(TestCase):
Unit tests for the 'Ip4Host' class.
"""
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the 'Ip4Host' object constructor.
"""
@@ -781,13 +781,13 @@ class TestIp4Host(TestCase):
"192.168.9.5",
)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
self.assertEqual(str(Ip4Host("192.168.9.100/24")), "192.168.9.100/24")
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -795,7 +795,7 @@ class TestIp4Host(TestCase):
repr(Ip4Host("172.16.0.50/12")), "Ip4Host('172.16.0.50/12')"
)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -803,7 +803,7 @@ class TestIp4Host(TestCase):
self.assertNotEqual(Ip4Host("0.0.0.0/0"), Ip4Host("0.0.0.0/32"))
self.assertNotEqual(Ip4Host("0.0.0.0/0"), Ip4Host("1.1.1.1/0"))
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dunder.
"""
@@ -812,13 +812,13 @@ class TestIp4Host(TestCase):
hash(Ip4Address("10.0.0.1")) ^ hash(Ip4Network("10.0.0.0/8")),
)
- def test_version(self):
+ def test_version(self) -> None:
"""
Test the 'version' property.
"""
self.assertEqual(Ip4Host("0.0.0.0/0").version, 4)
- def test_address(self):
+ def test_address(self) -> None:
"""
Test the 'address' property.
"""
@@ -826,7 +826,7 @@ class TestIp4Host(TestCase):
Ip4Host("192.168.9.100/24").address, Ip4Address("192.168.9.100")
)
- def test_network(self):
+ def test_network(self) -> None:
"""
Test the 'network' property.
"""

diff --git a/tests/unit/ip4_fpa.py b/tests/unit/ip4_fpa.py
index 94edd6e..eafee5f 100755
--- a/tests/unit/ip4_fpa.py
+++ b/tests/unit/ip4_fpa.py
@@ -63,14 +63,14 @@ class TestIp4Assembler(TestCase):
IPv4 packet assembler unit test class.
"""
- def test_ip4_fpa__ethertype(self):
+ def test_ip4_fpa__ethertype(self) -> None:
"""
Make sure the 'Ip4Assembler' class has the proper
'ethertype' value assigned.
"""
self.assertEqual(Ip4Assembler.ether_type, ETHER_TYPE_IP4)
- def test_ip4_fpa____init__(self):
+ def test_ip4_fpa____init__(self) -> None:
"""
Test the packet constructor.
"""
@@ -109,7 +109,7 @@ class TestIp4Assembler(TestCase):
IP4_HEADER_LEN + IP4_OPT_NOP_LEN + IP4_OPT_EOL_LEN + 16,
)
- def test_ip4_fpa____init____defaults(self):
+ def test_ip4_fpa____init____defaults(self) -> None:
"""
Test the packet constructor with default arguments.
"""
@@ -131,87 +131,87 @@ class TestIp4Assembler(TestCase):
self.assertEqual(packet._hlen, IP4_HEADER_LEN)
self.assertEqual(packet._plen, IP4_HEADER_LEN)
- def test_ip4_fpa____init____assert_ttl__under(self):
+ def test_ip4_fpa____init____assert_ttl__under(self) -> None:
"""
Test assertion for the 'ttl' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(ttl=-1)
- def test_ip4_fpa____init____assert_ttl__over(self):
+ def test_ip4_fpa____init____assert_ttl__over(self) -> None:
"""
Test assertion for the 'ttl' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(ttl=0x100)
- def test_ip4_fpa____init____assert_dscp__under(self):
+ def test_ip4_fpa____init____assert_dscp__under(self) -> None:
"""
Test assertion for the 'dscp' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(dscp=-1)
- def test_ip4_fpa____init____assert_dscp__over(self):
+ def test_ip4_fpa____init____assert_dscp__over(self) -> None:
"""
Test assertion for the 'dscp' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(dscp=0x40)
- def test_ip4_fpa____init____assert_ecn__under(self):
+ def test_ip4_fpa____init____assert_ecn__under(self) -> None:
"""
Test assertion for the 'ecn' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(ecn=-1)
- def test_ip4_fpa____init____assert_ecn__over(self):
+ def test_ip4_fpa____init____assert_ecn__over(self) -> None:
"""
Test assertion for the 'ecn' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(ecn=4)
- def test_ip4_fpa____init____assert_id__under(self):
+ def test_ip4_fpa____init____assert_id__under(self) -> None:
"""
Test assertion for the 'id' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(id=-1)
- def test_ip4_fpa____init____assert_id__over(self):
+ def test_ip4_fpa____init____assert_id__over(self) -> None:
"""
Test assertion for the 'id' argument.
"""
with self.assertRaises(AssertionError):
Ip4Assembler(id=0x10000)
- def test_ip4_fpa____init____assert_proto_udp(self):
+ def test_ip4_fpa____init____assert_proto_udp(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4Assembler(carried_packet=UdpAssembler())
- def test_ip4_fpa____init____assert_proto_tcp(self):
+ def test_ip4_fpa____init____assert_proto_tcp(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4Assembler(carried_packet=TcpAssembler())
- def test_ip4_fpa____init____assert_proto_icmp4(self):
+ def test_ip4_fpa____init____assert_proto_icmp4(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4Assembler(carried_packet=Icmp4Assembler())
- def test_ip4_fpa____init____assert_proto_raw(self):
+ def test_ip4_fpa____init____assert_proto_raw(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4Assembler(carried_packet=RawAssembler())
- def test_ip4_fpa____init____assert_proto_unknown(self):
+ def test_ip4_fpa____init____assert_proto_unknown(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
@@ -221,14 +221,14 @@ class TestIp4Assembler(TestCase):
carried_packet_mock.tracker = StrictMock(Tracker)
Ip4Assembler(carried_packet=carried_packet_mock)
- def test_ip4_fpa____len__(self):
+ def test_ip4_fpa____len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
packet = Ip4Assembler()
self.assertEqual(len(packet), IP4_HEADER_LEN)
- def test_ip4_fpa____len____options(self):
+ def test_ip4_fpa____len____options(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -239,7 +239,7 @@ class TestIp4Assembler(TestCase):
len(packet), IP4_HEADER_LEN + IP4_OPT_NOP_LEN + IP4_OPT_EOL_LEN
)
- def test_ip4_fpa____len____data(self):
+ def test_ip4_fpa____len____data(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -248,7 +248,7 @@ class TestIp4Assembler(TestCase):
)
self.assertEqual(len(packet), IP4_HEADER_LEN + 16)
- def test_ip4_fpa____len____options_data(self):
+ def test_ip4_fpa____len____options_data(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -260,7 +260,7 @@ class TestIp4Assembler(TestCase):
len(packet), IP4_HEADER_LEN + IP4_OPT_NOP_LEN + IP4_OPT_EOL_LEN + 16
)
- def test_ip4_fpa____str__(self):
+ def test_ip4_fpa____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -281,7 +281,7 @@ class TestIp4Assembler(TestCase):
"id 12345, DF, offset 0, plen 20, ttl 32",
)
- def test_ip4_fpa____str____options(self):
+ def test_ip4_fpa____str____options(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -302,7 +302,7 @@ class TestIp4Assembler(TestCase):
"DF, offset 0, plen 22, ttl 32, nop, eol",
)
- def test_ip4_fpa__tracker_getter(self):
+ def test_ip4_fpa__tracker_getter(self) -> None:
"""
Test the '_tracker' attribute getter.
"""
@@ -311,7 +311,7 @@ class TestIp4Assembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_ip4_fpa__dst_getter(self):
+ def test_ip4_fpa__dst_getter(self) -> None:
"""
Test the '_dst' attributer getter.
"""
@@ -322,7 +322,7 @@ class TestIp4Assembler(TestCase):
self.assertEqual(packet.dst, Ip4Address("5.6.7.8"))
- def test_ip4_fpa__src_getter(self):
+ def test_ip4_fpa__src_getter(self) -> None:
"""
Test the '_src' attribute getter.
"""
@@ -331,14 +331,14 @@ class TestIp4Assembler(TestCase):
)
self.assertEqual(packet.src, Ip4Address("1.2.3.4"))
- def test_ip4_fpa__hlen_getter(self):
+ def test_ip4_fpa__hlen_getter(self) -> None:
"""
Test the '_hlen' attribute getter.
"""
packet = Ip4Assembler()
self.assertEqual(packet._hlen, IP4_HEADER_LEN)
- def test_ip4_fpa__hlen_getter__options(self):
+ def test_ip4_fpa__hlen_getter__options(self) -> None:
"""
Test the '_hlen' attribute getter with options present.
"""
@@ -347,14 +347,14 @@ class TestIp4Assembler(TestCase):
packet.hlen, IP4_HEADER_LEN + IP4_OPT_NOP_LEN + IP4_OPT_EOL_LEN
)
- def test_ip4_fpa__proto_getter(self):
+ def test_ip4_fpa__proto_getter(self) -> None:
"""
Test the '_proto' attribute getter.
"""
packet = Ip4Assembler()
self.assertEqual(packet.proto, IP4_PROTO_RAW)
- def test_ip4_fpa__dlen_getter(self):
+ def test_ip4_fpa__dlen_getter(self) -> None:
"""
Test the '_dlen' attribute getter.
"""
@@ -363,7 +363,7 @@ class TestIp4Assembler(TestCase):
)
self.assertEqual(packet.dlen, 16)
- def test_ip4_fpa__pshdr_sum(self):
+ def test_ip4_fpa__pshdr_sum(self) -> None:
"""
Test the 'pshdr_sum' property.
"""
@@ -375,7 +375,7 @@ class TestIp4Assembler(TestCase):
self.assertEqual(packet.pshdr_sum, 117901852)
- def test_ip4_fpa___raw_options(self):
+ def test_ip4_fpa___raw_options(self) -> None:
"""
Test the '_raw_options' attribute getter.
"""
@@ -384,7 +384,7 @@ class TestIp4Assembler(TestCase):
)
self.assertEqual(packet._raw_options, b"\x01\x00")
- def test_ip4_fpa__assemble(self):
+ def test_ip4_fpa__assemble(self) -> None:
"""
Test the 'assemble()' method.
"""
@@ -413,13 +413,13 @@ class TestIp4FragAssembler(TestCase):
IPv4 fragment packet assembler unit test class.
"""
- def test_ip4_frag_fpa__ethertype(self):
+ def test_ip4_frag_fpa__ethertype(self) -> None:
"""
Test the 'ethertype' property of the 'Ip4FragAssembler' class.
"""
self.assertEqual(Ip4Assembler.ether_type, ETHER_TYPE_IP4)
- def test_ip4_frag_fpa____init__(self):
+ def test_ip4_frag_fpa____init__(self) -> None:
"""
Test the packet constructor.
"""
@@ -456,7 +456,7 @@ class TestIp4FragAssembler(TestCase):
IP4_HEADER_LEN + IP4_OPT_NOP_LEN + IP4_OPT_EOL_LEN + 16,
)
- def test_ip4_frag_fpa____init____defaults(self):
+ def test_ip4_frag_fpa____init____defaults(self) -> None:
"""
Test the packet constructor with default arguments.
"""
@@ -477,101 +477,101 @@ class TestIp4FragAssembler(TestCase):
self.assertEqual(packet._hlen, IP4_HEADER_LEN)
self.assertEqual(packet._plen, IP4_HEADER_LEN)
- def test_ip4_frag_fpa____init____assert_ttl__under(self):
+ def test_ip4_frag_fpa____init____assert_ttl__under(self) -> None:
"""
Test assertion for the 'ttl' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(ttl=-1)
- def test_ip4_frag_fpa____init____assert_ttl__over(self):
+ def test_ip4_frag_fpa____init____assert_ttl__over(self) -> None:
"""
Test assertion for the 'ttl' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(ttl=0x100)
- def test_ip4_frag_fpa____init____assert_dscp__under(self):
+ def test_ip4_frag_fpa____init____assert_dscp__under(self) -> None:
"""
Test assertion for the 'dscp' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(dscp=-1)
- def test_ip4_frag_fpa____init____assert_dscp__over(self):
+ def test_ip4_frag_fpa____init____assert_dscp__over(self) -> None:
"""
Test assertion for the 'dscp' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(dscp=0x40)
- def test_ip4_frag_fpa____init____assert_ecn__under(self):
+ def test_ip4_frag_fpa____init____assert_ecn__under(self) -> None:
"""
Test assertion for the 'ecn' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(ecn=-1)
- def test_ip4_frag_fpa____init____assert_ecn__over(self):
+ def test_ip4_frag_fpa____init____assert_ecn__over(self) -> None:
"""
Test assertion for the 'ecn' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(ecn=4)
- def test_ip4_frag_fpa____init____assert_id__under(self):
+ def test_ip4_frag_fpa____init____assert_id__under(self) -> None:
"""
Test assertion for the 'id' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(id=-1)
- def test_ip4_frag_fpa____init____assert_id__over(self):
+ def test_ip4_frag_fpa____init____assert_id__over(self) -> None:
"""
Test assertion for the 'id' argument.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(id=0x10000)
- def test_ip4_frag_fpa____init____assert_proto_udp(self):
+ def test_ip4_frag_fpa____init____assert_proto_udp(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4FragAssembler(proto=IP4_PROTO_UDP)
- def test_ip4_frag_fpa____init____assert_proto_tcp(self):
+ def test_ip4_frag_fpa____init____assert_proto_tcp(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4FragAssembler(proto=IP4_PROTO_TCP)
- def test_ip4_frag_fpa____init____assert_proto_icmp4(self):
+ def test_ip4_frag_fpa____init____assert_proto_icmp4(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4FragAssembler(proto=IP4_PROTO_ICMP4)
- def test_ip4_frag_fpa____init____assert_proto_raw(self):
+ def test_ip4_frag_fpa____init____assert_proto_raw(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
Ip4FragAssembler(proto=IP4_PROTO_RAW)
- def test_ip4_frag_fpa____init____assert_proto_unknown(self):
+ def test_ip4_frag_fpa____init____assert_proto_unknown(self) -> None:
"""
Test assertion for the carried packet 'ip4_proto' attribute.
"""
with self.assertRaises(AssertionError):
Ip4FragAssembler(proto=-1)
- def test_ip4_frag_fpa____len__(self):
+ def test_ip4_frag_fpa____len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
packet = Ip4FragAssembler()
self.assertEqual(len(packet), IP4_HEADER_LEN)
- def test_ip4_frag_fpa____len____options(self):
+ def test_ip4_frag_fpa____len____options(self) -> None:
"""
Test '__len__()' dunder with options present.
"""
@@ -582,7 +582,7 @@ class TestIp4FragAssembler(TestCase):
len(packet), IP4_HEADER_LEN + IP4_OPT_NOP_LEN + IP4_OPT_EOL_LEN
)
- def test_ip4_frag_fpa____len____data(self):
+ def test_ip4_frag_fpa____len____data(self) -> None:
"""
Test the '__len__()' dunder with data present.
"""
@@ -591,7 +591,7 @@ class TestIp4FragAssembler(TestCase):
)
self.assertEqual(len(packet), IP4_HEADER_LEN + 16)
- def test_ip4_frag_fpa____len____options_data(self):
+ def test_ip4_frag_fpa____len____options_data(self) -> None:
"""
Test the '__len__() dunder with options and data present.
@@ -604,7 +604,7 @@ class TestIp4FragAssembler(TestCase):
len(packet), IP4_HEADER_LEN + IP4_OPT_NOP_LEN + IP4_OPT_EOL_LEN + 16
)
- def test_ip4_frag_fpa____str__(self):
+ def test_ip4_frag_fpa____str__(self) -> None:
"""
Test the '__str__() dunder.
"""
@@ -627,7 +627,7 @@ class TestIp4FragAssembler(TestCase):
"MF, offset 54321, plen 20, ttl 32",
)
- def test_ip4_frag_fpa____str____options(self):
+ def test_ip4_frag_fpa____str____options(self) -> None:
"""
Test the '__str__()' dunder with options present.
"""
@@ -650,7 +650,7 @@ class TestIp4FragAssembler(TestCase):
"MF, offset 54321, plen 22, ttl 32, nop, eol",
)
- def test_ip4_frag_fpa__tracker_getter(self):
+ def test_ip4_frag_fpa__tracker_getter(self) -> None:
"""
Test the '_tracker' attribute getter.
"""
@@ -659,7 +659,7 @@ class TestIp4FragAssembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_ip4_frag_fpa__dst_getter(self):
+ def test_ip4_frag_fpa__dst_getter(self) -> None:
"""
Test the '_dst attribute' getter.
"""
@@ -668,7 +668,7 @@ class TestIp4FragAssembler(TestCase):
)
self.assertEqual(packet.dst, Ip4Address("5.6.7.8"))
- def test_ip4_frag_fpa__src_getter(self):
+ def test_ip4_frag_fpa__src_getter(self) -> None:
"""
Test the '_src' attribute getter.
"""
@@ -677,7 +677,7 @@ class TestIp4FragAssembler(TestCase):
)
self.assertEqual(packet.src, Ip4Address("1.2.3.4"))
- def test_ip4_frag_fpa___raw_options(self):
+ def test_ip4_frag_fpa___raw_options(self) -> None:
"""
Test the '_raw_options' attribute getter.
"""
@@ -686,7 +686,7 @@ class TestIp4FragAssembler(TestCase):
)
self.assertEqual(packet._raw_options, b"\x01\x00")
- def test_ip4_frag_fpa__assemble(self):
+ def test_ip4_frag_fpa__assemble(self) -> None:
"""
Test the 'assemble() method.
"""
@@ -717,28 +717,28 @@ class TestIp4OptEol(TestCase):
IPv4 EOL option unit test class.
"""
- def test_ip4_fpa_opt_eol____str__(self):
+ def test_ip4_fpa_opt_eol____str__(self) -> None:
"""
Test the '__str__() dunder.
"""
option = Ip4OptEol()
self.assertEqual(str(option), "eol")
- def test_ip4_fpa_opt_eol____repr__(self):
+ def test_ip4_fpa_opt_eol____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = Ip4OptEol()
self.assertEqual(repr(option), "Ip4OptEol()")
- def test_ip4_fpa_opt_eol____bytes__(self):
+ def test_ip4_fpa_opt_eol____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = Ip4OptEol()
self.assertEqual(bytes(option), b"\x00")
- def test_ip4_fpa_opt_eol____eq__(self):
+ def test_ip4_fpa_opt_eol____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -751,28 +751,28 @@ class TestIp4OptNop(TestCase):
IPv4 NOP option unit test class.
"""
- def test_ip4_fpa_opt_nop____str__(self):
+ def test_ip4_fpa_opt_nop____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
option = Ip4OptNop()
self.assertEqual(str(option), "nop")
- def test_ip4_fpa_opt_nop____repr__(self):
+ def test_ip4_fpa_opt_nop____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = Ip4OptNop()
self.assertEqual(repr(option), "Ip4OptNop()")
- def test_ip4_fpa_opt_nop____bytes__(self):
+ def test_ip4_fpa_opt_nop____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = Ip4OptNop()
self.assertEqual(bytes(option), b"\x01")
- def test_ip4_fpa_opt_nop____eq__(self):
+ def test_ip4_fpa_opt_nop____eq__(self) -> None:
"""
Test the '__eq__' dunder.
"""

diff --git a/tests/unit/ip4_phtx.py b/tests/unit/ip4_phtx.py
index 112ee94..9ee2ed8 100755
--- a/tests/unit/ip4_phtx.py
+++ b/tests/unit/ip4_phtx.py
@@ -51,7 +51,7 @@ class TestIp4Phtx(TestCase):
IPv4 packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Setup tests.
"""
@@ -62,7 +62,9 @@ class TestIp4Phtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_ip4_phtx__ip4_to_unicast_address_on_local_network__src_valid(self):
+ def test_ip4_phtx__ip4_to_unicast_address_on_local_network__src_valid(
+ self,
+ ) -> None:
"""
Test sending IPv4 packet to unicast address on local network,
valid source.
@@ -335,7 +337,9 @@ class TestIp4Phtx(TestCase):
),
)
- def test_ip4_phtx__ip4_to_unspecified_address__dst_unspecified_drop(self):
+ def test_ip4_phtx__ip4_to_unspecified_address__dst_unspecified_drop(
+ self,
+ ) -> None:
"""
Test sending IPv4 packet to unspecified address.
"""
@@ -353,7 +357,7 @@ class TestIp4Phtx(TestCase):
),
)
- def test_ip4_phtx__ip4_fragmentation(self):
+ def test_ip4_phtx__ip4_fragmentation(self) -> None:
"""
Test sending IPv4 packet large enough to require fragmentation.
"""

diff --git a/tests/unit/ip6_address.py b/tests/unit/ip6_address.py
index 98b8605..424ad9c 100755
--- a/tests/unit/ip6_address.py
+++ b/tests/unit/ip6_address.py
@@ -53,7 +53,7 @@ class TestIp6Address(TestCase):
Unit tests for 'Ip6Address' class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Setup tests.
"""
@@ -118,7 +118,7 @@ class TestIp6Address(TestCase):
),
]
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the 'Ip6Address' object constructor.
"""
@@ -197,7 +197,7 @@ class TestIp6Address(TestCase):
340282366920938463463374607431768211456,
)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -206,7 +206,7 @@ class TestIp6Address(TestCase):
"2001::1234:5678:90ab:cdef",
)
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -215,7 +215,7 @@ class TestIp6Address(TestCase):
"Ip6Address('2001::1234:5678:90ab:cdef')",
)
- def test___bytes__(self):
+ def test___bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
@@ -224,7 +224,7 @@ class TestIp6Address(TestCase):
b" \x01\x00\x00\x00\x00\x00\x00\x124Vx\x90\xab\xcd\xef",
)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -233,7 +233,7 @@ class TestIp6Address(TestCase):
Ip6Address("2001::1234:5678:90ab:cdef"),
)
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dunder.
"""
@@ -242,13 +242,13 @@ class TestIp6Address(TestCase):
hash(42540488161975842761862124892595146223),
)
- def test_version(self):
+ def test_version(self) -> None:
"""
Test the 'version' property.
"""
self.assertEqual(Ip6Address("2001::1234:5678:90ab:cdef").version, 6)
- def test_is_unspecified(self):
+ def test_is_unspecified(self) -> None:
"""
Test the 'is_unspecified' property.
"""
@@ -257,28 +257,28 @@ class TestIp6Address(TestCase):
sample.ip6_address.is_unspecified, sample.is_unspecified
)
- def test_is_loopback(self):
+ def test_is_loopback(self) -> None:
"""
Test the 'is_loopback' property.
"""
for sample in self.ip6_samples:
self.assertEqual(sample.ip6_address.is_loopback, sample.is_loopback)
- def test_is_global(self):
+ def test_is_global(self) -> None:
"""
Test the 'is_global' property.
"""
for sample in self.ip6_samples:
self.assertEqual(sample.ip6_address.is_global, sample.is_global)
- def test_is_private(self):
+ def test_is_private(self) -> None:
"""
Test the 'is_private' property.
"""
for sample in self.ip6_samples:
self.assertEqual(sample.ip6_address.is_private, sample.is_private)
- def test_is_link_local(self):
+ def test_is_link_local(self) -> None:
"""
Test the 'is_link_local' property.
"""
@@ -287,7 +287,7 @@ class TestIp6Address(TestCase):
sample.ip6_address.is_link_local, sample.is_link_local
)
- def test_is_multicast(self):
+ def test_is_multicast(self) -> None:
"""
Test the 'is_multicast' property.
"""
@@ -296,7 +296,7 @@ class TestIp6Address(TestCase):
sample.ip6_address.is_multicast, sample.is_multicast
)
- def test_is_solicited_node_multicast(self):
+ def test_is_solicited_node_multicast(self) -> None:
"""
Test the 'is_solicited_multicast' property.
"""
@@ -306,14 +306,14 @@ class TestIp6Address(TestCase):
sample.is_solicited_node_multicast,
)
- def test_is_unicast(self):
+ def test_is_unicast(self) -> None:
"""
Test the 'is_unicast' property.
"""
for sample in self.ip6_samples:
self.assertEqual(sample.ip6_address.is_unicast, sample.is_unicast)
- def test_solicited_node_multicast(self):
+ def test_solicited_node_multicast(self) -> None:
"""
Test the 'solicited_node_multicast' property.
"""
@@ -322,7 +322,7 @@ class TestIp6Address(TestCase):
Ip6Address("ff02::1:ffab:cdef"),
)
- def test_multicast_mac(self):
+ def test_multicast_mac(self) -> None:
"""
Test the 'multicast_mac' property.
"""
@@ -331,7 +331,7 @@ class TestIp6Address(TestCase):
MacAddress("33:33:ff:ab:cd:ef"),
)
- def test_unspecified(self):
+ def test_unspecified(self) -> None:
"""
Test the 'unspecified' property.
"""
@@ -346,7 +346,7 @@ class TestIp6Mask(TestCase):
Unit tests for 'Ip6Mask' class.
"""
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the constructor for 'Ip6Mask' object.
"""
@@ -400,19 +400,19 @@ class TestIp6Mask(TestCase):
)
self.assertRaises(Ip6MaskFormatError, Ip6Mask, 64)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
self.assertEqual(str(Ip6Mask("/64")), "/64")
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
self.assertEqual(repr(Ip6Mask("/80")), "Ip6Mask('/80')")
- def test___bytes__(self):
+ def test___bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
@@ -426,7 +426,7 @@ class TestIp6Mask(TestCase):
b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00",
)
- def test___int__(self):
+ def test___int__(self) -> None:
"""
Test the '__int__()' dunder.
"""
@@ -434,14 +434,14 @@ class TestIp6Mask(TestCase):
int(Ip6Mask("/48")), 340282366920937254537554992802593505280
)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
self.assertEqual(Ip6Mask("/64"), Ip6Mask("/64"))
self.assertNotEqual(Ip6Mask("/64"), Ip6Mask("/128"))
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__' dunder.
"""
@@ -449,14 +449,14 @@ class TestIp6Mask(TestCase):
hash(Ip6Mask("/64")), hash(340282366920938463444927863358058659840)
)
- def test___len__(self):
+ def test___len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
for n in range(129):
self.assertEqual(len(Ip6Mask(f"/{n}")), n)
- def test_version(self):
+ def test_version(self) -> None:
"""
Test the 'version' property.
"""
@@ -468,7 +468,7 @@ class TestIp6Network(TestCase):
Unit tests for 'Ip6Network' class.
"""
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the constructor for 'Ip6Network' object.
"""
@@ -517,7 +517,7 @@ class TestIp6Network(TestCase):
Ip6NetworkFormatError, Ip6Network, "1234:5678:90ab:cdef::"
)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -526,7 +526,7 @@ class TestIp6Network(TestCase):
"1234:5678:90ab:cdef::/64",
)
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -535,14 +535,14 @@ class TestIp6Network(TestCase):
"Ip6Network('1234:5678:90ab:cdef::/64')",
)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
self.assertEqual(Ip6Network("::/0"), Ip6Network("::/0"))
self.assertNotEqual(Ip6Network("::/0"), Ip6Network("::/128"))
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dunder.
"""
@@ -551,7 +551,7 @@ class TestIp6Network(TestCase):
hash(Ip6Address("1234:5678:90ab:cdef::")) ^ hash(Ip6Mask("/64")),
)
- def test___contains__(self):
+ def test___contains__(self) -> None:
"""
Test the '__contains__()' dunder.
"""
@@ -565,7 +565,7 @@ class TestIp6Network(TestCase):
Ip6Address("2002::1234:5678:90ab:cdef"), Ip6Network("2001::/64")
)
- def test_address(self):
+ def test_address(self) -> None:
"""
Test the 'address' property.
"""
@@ -574,7 +574,7 @@ class TestIp6Network(TestCase):
Ip6Address("1234:5678:90ab:cdef::"),
)
- def test_mask(self):
+ def test_mask(self) -> None:
"""
Test the 'mask' property.
"""
@@ -582,7 +582,7 @@ class TestIp6Network(TestCase):
Ip6Network("1234:5678:90ab:cdef::/64").mask, Ip6Mask("/64")
)
- def test_last(self):
+ def test_last(self) -> None:
"""
Test the 'last' property.
"""
@@ -591,7 +591,7 @@ class TestIp6Network(TestCase):
Ip6Address("1234:5678:90ab:cdef:ffff:ffff:ffff:ffff"),
)
- def test_eui64(self):
+ def test_eui64(self) -> None:
"""
Test the 'eui64' property.
"""
@@ -602,7 +602,7 @@ class TestIp6Network(TestCase):
Ip6Host("1234:5678:90ab:cdef:302:3ff:fe04:506/64"),
)
- def test_version(self):
+ def test_version(self) -> None:
self.assertEqual(Ip6Network("1234:5678:90ab:cdef::/64").version, 6)
@@ -611,7 +611,7 @@ class TestIp6Host(TestCase):
Unit tests for 'Ip6Host' class.
"""
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the constructor for 'Ip6Host' object.
"""
@@ -666,7 +666,7 @@ class TestIp6Host(TestCase):
)
self.assertRaises(Ip6HostFormatError, Ip6Host, "1234:5678:90ab:cdef::1")
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -675,7 +675,7 @@ class TestIp6Host(TestCase):
"1234:5678:90ab:cdef::1/64",
)
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -684,7 +684,7 @@ class TestIp6Host(TestCase):
"Ip6Host('1234:5678:90ab:cdef::1/64')",
)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -700,7 +700,7 @@ class TestIp6Host(TestCase):
Ip6Host("1234:5678:90ab:cdef::1/64"), Ip6Host("::/64")
)
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dunder.
"""
@@ -710,7 +710,7 @@ class TestIp6Host(TestCase):
^ hash(Ip6Network("1234:5678:90ab:cdef::/64")),
)
- def test_address(self):
+ def test_address(self) -> None:
"""
Test the 'address' property.
"""
@@ -719,7 +719,7 @@ class TestIp6Host(TestCase):
Ip6Address("1234:5678:90ab:cdef::1"),
)
- def test_network(self):
+ def test_network(self) -> None:
"""
Test the 'network' property.
"""
@@ -728,7 +728,7 @@ class TestIp6Host(TestCase):
Ip6Network("1234:5678:90ab:cdef::/64"),
)
- def test_version(self):
+ def test_version(self) -> None:
"""
Test the 'version' property.
"""

diff --git a/tests/unit/ip6_fpa.py b/tests/unit/ip6_fpa.py
index 1386fec..63daf6f 100755
--- a/tests/unit/ip6_fpa.py
+++ b/tests/unit/ip6_fpa.py
@@ -50,14 +50,14 @@ class TestIp6Assembler(TestCase):
IPv6 packet assembler unit test class.
"""
- def test_ip6_fpa__ethertype(self):
+ def test_ip6_fpa__ethertype(self) -> None:
"""
Make sure the 'Ip6Assembler' class has the proper
'ethertype' value assigned.
"""
self.assertEqual(Ip6Assembler.ether_type, ETHER_TYPE_IP6)
- def test_ip6_fpa____init__(self):
+ def test_ip6_fpa____init__(self) -> None:
"""
Test the packet constructor.
"""
@@ -84,7 +84,7 @@ class TestIp6Assembler(TestCase):
self.assertEqual(packet._next, IP6_NEXT_RAW)
self.assertEqual(packet._dlen, 16)
- def test_ip6_fpa____init____defaults(self):
+ def test_ip6_fpa____init____defaults(self) -> None:
"""
Test the packet constructor with default arguments.
"""
@@ -101,87 +101,87 @@ class TestIp6Assembler(TestCase):
self.assertEqual(packet._next, IP6_NEXT_RAW)
self.assertEqual(packet._dlen, 0)
- def test_ip6_fpa____init____assert_hop__under(self):
+ def test_ip6_fpa____init____assert_hop__under(self) -> None:
"""
Test assertion for the the 'hop' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(hop=-1)
- def test_ip6_fpa____init____assert_hop__over(self):
+ def test_ip6_fpa____init____assert_hop__over(self) -> None:
"""
Test assertion for the 'hop' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(hop=0x100)
- def test_ip6_fpa____init____assert_dscp__under(self):
+ def test_ip6_fpa____init____assert_dscp__under(self) -> None:
"""
Test assertion for the 'dscp' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(dscp=-1)
- def test_ip6_fpa____init____assert_dscp__over(self):
+ def test_ip6_fpa____init____assert_dscp__over(self) -> None:
"""
Test assertion for the 'dscp' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(dscp=0x40)
- def test_ip6_fpa____init____assert_ecn__under(self):
+ def test_ip6_fpa____init____assert_ecn__under(self) -> None:
"""
Test assertion for the 'ecn' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(ecn=-1)
- def test_ip6_fpa____init____assert_ecn__over(self):
+ def test_ip6_fpa____init____assert_ecn__over(self) -> None:
"""
Test assertion for the 'ecn' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(ecn=4)
- def test_ip6_fpa____init____assert_flow__under(self):
+ def test_ip6_fpa____init____assert_flow__under(self) -> None:
"""
Test assertion for the 'flow' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(flow=-1)
- def test_ip6_fpa____init____assert_flow__over(self):
+ def test_ip6_fpa____init____assert_flow__over(self) -> None:
"""
Test assertion for the 'flow' argument.
"""
with self.assertRaises(AssertionError):
Ip6Assembler(flow=0x1000000)
- def test_ip6_fpa____init____assert_next_header_udp(self):
+ def test_ip6_fpa____init____assert_next_header_udp(self) -> None:
"""
Test assertion for carried packet 'ip6_next_header' attribute.
"""
Ip6Assembler(carried_packet=UdpAssembler())
- def test_ip6_fpa____init____assert_next_header_tcp(self):
+ def test_ip6_fpa____init____assert_next_header_tcp(self) -> None:
"""
Test assertion for carried packet 'ip6_next_header' attribute.
"""
Ip6Assembler(carried_packet=TcpAssembler())
- def test_ip6_fpa____init____assert_next_header_icmp6(self):
+ def test_ip6_fpa____init____assert_next_header_icmp6(self) -> None:
"""
Test assertion for carried packet 'ip6_next_header' attribute.
"""
Ip6Assembler(carried_packet=Icmp6Assembler())
- def test_ip6_fpa____init____assert_next_header_raw(self):
+ def test_ip6_fpa____init____assert_next_header_raw(self) -> None:
"""
Test assertion for carried packet 'ip6_next_header' attribute.
"""
Ip6Assembler(carried_packet=RawAssembler())
- def test_ip6_fpa____init____assert_next_header_unknown(self):
+ def test_ip6_fpa____init____assert_next_header_unknown(self) -> None:
"""
Test assertion for carried packet 'ip6_next_header' attribute.
"""
@@ -191,7 +191,7 @@ class TestIp6Assembler(TestCase):
carried_packet_mock.tracker = StrictMock(Tracker)
Ip6Assembler(carried_packet=carried_packet_mock)
- def test_ip6_fpa____len__(self):
+ def test_ip6_fpa____len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -199,7 +199,7 @@ class TestIp6Assembler(TestCase):
self.assertEqual(len(packet), IP6_HEADER_LEN)
- def test_ip6_fpa____len____data(self):
+ def test_ip6_fpa____len____data(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -208,7 +208,7 @@ class TestIp6Assembler(TestCase):
)
self.assertEqual(len(packet), IP6_HEADER_LEN + 16)
- def test_ip6_fpa____str__(self):
+ def test_ip6_fpa____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -226,7 +226,7 @@ class TestIp6Assembler(TestCase):
"IPv6 0:1:2:3:4:5:6:7 > 8:9:a:b:c:d:e:f, next 255 (raw_data), flow 12345678, dlen 16, hop 32",
)
- def test_ip6_fpa__tracker_getter(self):
+ def test_ip6_fpa__tracker_getter(self) -> None:
"""
Test the '_tracker' attribute getter.
"""
@@ -235,7 +235,7 @@ class TestIp6Assembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_ip6_fpa__dst_getter(self):
+ def test_ip6_fpa__dst_getter(self) -> None:
"""
Test the '_dst' attribute getter.
"""
@@ -244,7 +244,7 @@ class TestIp6Assembler(TestCase):
)
self.assertEqual(packet.dst, Ip6Address("8:9:A:B:C:D:E:F"))
- def test_ip6_fpa__src_getter(self):
+ def test_ip6_fpa__src_getter(self) -> None:
"""
Test the '_src' attribute getter.
"""
@@ -253,7 +253,7 @@ class TestIp6Assembler(TestCase):
)
self.assertEqual(packet.src, Ip6Address("0:1:2:3:4:5:6:7"))
- def test_ip6_fpa__dlen_getter(self):
+ def test_ip6_fpa__dlen_getter(self) -> None:
"""
Test the 'dlen' property.
"""
@@ -262,14 +262,14 @@ class TestIp6Assembler(TestCase):
)
self.assertEqual(packet._dlen, 16)
- def test_ip6_fpa__next_getter(self):
+ def test_ip6_fpa__next_getter(self) -> None:
"""
Test the 'next' property getter.
"""
packet = Ip6Assembler()
self.assertEqual(packet.next, IP6_NEXT_RAW)
- def test_ip6_fpa__pshdr_sum(self):
+ def test_ip6_fpa__pshdr_sum(self) -> None:
"""
Test the 'pshdr_sum' property getter.
"""
@@ -280,7 +280,7 @@ class TestIp6Assembler(TestCase):
)
self.assertEqual(packet.pshdr_sum, 6755588421714211)
- def test_ip6_fpa__assemble(self):
+ def test_ip6_fpa__assemble(self) -> None:
"""
Test the 'assemble() method.
"""

diff --git a/tests/unit/ip6_phtx.py b/tests/unit/ip6_phtx.py
index 355375a..2254598 100755
--- a/tests/unit/ip6_phtx.py
+++ b/tests/unit/ip6_phtx.py
@@ -51,7 +51,7 @@ class TestIp6Phtx(TestCase):
IPv6 packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Setup tests.
"""
@@ -62,7 +62,9 @@ class TestIp6Phtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_ip6_phtx__ip6_to_unicast_address_on_local_network__src_valid(self):
+ def test_ip6_phtx__ip6_to_unicast_address_on_local_network__src_valid(
+ self,
+ ) -> None:
"""
Test sending IPv6 packet to unicast address on local network,
valid source.
@@ -250,7 +252,9 @@ class TestIp6Phtx(TestCase):
),
)
- def test_ip6_phtx__ip6_to_unspecified_address__dst_unspecified_drop(self):
+ def test_ip6_phtx__ip6_to_unspecified_address__dst_unspecified_drop(
+ self,
+ ) -> None:
"""
Test sending IPv6 packet to unspecified address.
"""
@@ -268,7 +272,7 @@ class TestIp6Phtx(TestCase):
),
)
- def test_ip6_phtx__ip6_fragmentation(self):
+ def test_ip6_phtx__ip6_fragmentation(self) -> None:
"""
Test sending IPv6 packet large enough to require fragmentation.
"""

diff --git a/tests/unit/ip_helper.py b/tests/unit/ip_helper.py
index 1d4b3cb..d0fd7f2 100755
--- a/tests/unit/ip_helper.py
+++ b/tests/unit/ip_helper.py
@@ -43,7 +43,7 @@ class TestIpHelper(TestCase):
IP helper library unit test class.
"""
- def test_inet_cksum(self):
+ def test_inet_cksum(self) -> None:
"""
Test calculating the Internet Checksum
"""
@@ -87,7 +87,7 @@ class TestIpHelper(TestCase):
result = inet_cksum(data=memoryview(sample.data), init=sample.init)
self.assertEqual(result, sample.result)
- def test_ip_version(self):
+ def test_ip_version(self) -> None:
"""
Test detecting the version of IP protocol.
"""

diff --git a/tests/unit/mac_address.py b/tests/unit/mac_address.py
index beba21a..e774819 100755
--- a/tests/unit/mac_address.py
+++ b/tests/unit/mac_address.py
@@ -43,7 +43,7 @@ class TestMacAddress(TestCase):
Unit tests for the 'MacAddress' class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Setup tests.
"""
@@ -71,7 +71,7 @@ class TestMacAddress(TestCase):
MacSample(MacAddress("ff:ff:ff:ff:ff:ff"), is_broadcast=True),
]
- def test___init__(self):
+ def test___init__(self) -> None:
"""
Test the constructor for 'MacAddress' object.
"""
@@ -132,7 +132,7 @@ class TestMacAddress(TestCase):
281474976710656,
)
- def test___str__(self):
+ def test___str__(self) -> None:
"""
Test the '__str__()' dunder.'
"""
@@ -141,7 +141,7 @@ class TestMacAddress(TestCase):
"ff:00:ab:c7:d4:33",
)
- def test___repr__(self):
+ def test___repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
@@ -150,7 +150,7 @@ class TestMacAddress(TestCase):
"MacAddress('01:23:45:ab:cd:ef')",
)
- def test___bytes__(self):
+ def test___bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
@@ -159,7 +159,7 @@ class TestMacAddress(TestCase):
b"\x01#E\xab\xcd\xef",
)
- def test___int__(self):
+ def test___int__(self) -> None:
"""
Test the '__int__()' dunder.
"""
@@ -168,7 +168,7 @@ class TestMacAddress(TestCase):
1251004370415,
)
- def test___eq__(self):
+ def test___eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -181,7 +181,7 @@ class TestMacAddress(TestCase):
MacAddress("11:11:11:11:11:11"),
)
- def test___hash__(self):
+ def test___hash__(self) -> None:
"""
Test the '__hash__()' dunder.
"""
@@ -190,7 +190,7 @@ class TestMacAddress(TestCase):
1251004370415,
)
- def test_is_iunicast(self):
+ def test_is_iunicast(self) -> None:
"""
Test the 'is_unicast' property.
"""
@@ -200,7 +200,7 @@ class TestMacAddress(TestCase):
sample.is_unicast,
)
- def test_is_multicast_ip4(self):
+ def test_is_multicast_ip4(self) -> None:
"""
Test the 'is_multicast_ip4' property.
"""
@@ -210,7 +210,7 @@ class TestMacAddress(TestCase):
sample.is_multicast_ip4,
)
- def test_is_multicast_ip6(self):
+ def test_is_multicast_ip6(self) -> None:
"""
Test the 'is_multicast_ip6' property.
"""
@@ -220,7 +220,7 @@ class TestMacAddress(TestCase):
sample.is_multicast_ip6,
)
- def test_is_multicast_ip6_solicited_node(self):
+ def test_is_multicast_ip6_solicited_node(self) -> None:
"""
Test the 'is_multicast_ip6_solicited_node' property.
"""
@@ -230,7 +230,7 @@ class TestMacAddress(TestCase):
sample.is_multicast_ip6_solicited_node,
)
- def test_is_broadcast(self):
+ def test_is_broadcast(self) -> None:
"""
Test 'is_broadcast' property.
"""

diff --git a/tests/unit/mock_network.py b/tests/unit/mock_network.py
index 9d79afe..7069452 100755
--- a/tests/unit/mock_network.py
+++ b/tests/unit/mock_network.py
@@ -59,7 +59,7 @@ class MockNetworkSettings:
Mock network setting to mimic the above network.
"""
- def __init__(self):
+ def __init__(self) -> None:
"""
Mock class constructor.
"""
@@ -155,7 +155,7 @@ def patch_config(self, *, enable_log=False):
continue
-def setup_mock_packet_handler(self):
+def setup_mock_packet_handler(self) -> None:
"""
Prepare packet handler so it can pass packets without need of being
physically connected to the network.

diff --git a/tests/unit/packet_handler.py b/tests/unit/packet_handler.py
index 16ed6d5..0261903 100755
--- a/tests/unit/packet_handler.py
+++ b/tests/unit/packet_handler.py
@@ -44,7 +44,7 @@ class TestPacketHandler(TestCase):
Packet handler main unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Set up the test environment.
"""
@@ -54,7 +54,7 @@ class TestPacketHandler(TestCase):
).to_return_value(None)
self.packet_handler = PacketHandler()
- def test__parse_stack_ip6_address_candidate(self):
+ def test__parse_stack_ip6_address_candidate(self) -> None:
"""
Test the '_parse_stack_ip6_address_candidate()' method.
"""
@@ -125,7 +125,7 @@ class TestPacketHandler(TestCase):
result = [ip6_address.gateway for ip6_address in result]
self.assertEqual(result, expected)
- def test_parse_stack_ip4_host_candidate(self):
+ def test_parse_stack_ip4_host_candidate(self) -> None:
sample = [
(
"192.168.9.7/24",

diff --git a/tests/unit/tcp_fpa.py b/tests/unit/tcp_fpa.py
index 97cda0f..bdd885c 100755
--- a/tests/unit/tcp_fpa.py
+++ b/tests/unit/tcp_fpa.py
@@ -57,21 +57,21 @@ class TestTcpAssembler(TestCase):
TCP protocol assembler unit test class.
"""
- def test_tcp_fpa__ip4_proto_tcp(self):
+ def test_tcp_fpa__ip4_proto_tcp(self) -> None:
"""
Make sure the 'TcpAssembler' class has the proper
'ip4_proto' value assigned.
"""
self.assertEqual(TcpAssembler.ip4_proto, IP4_PROTO_TCP)
- def test_tcp_fpa__ip6_next_tcp(self):
+ def test_tcp_fpa__ip6_next_tcp(self) -> None:
"""
Make sure the 'TcpAssembler' class has the proper
'ip6_next' value assigned.
"""
self.assertEqual(TcpAssembler.ip6_next, IP6_NEXT_TCP)
- def test_tcp_fpa____init__(self):
+ def test_tcp_fpa____init__(self) -> None:
"""
Test the class constructor.
"""
@@ -189,7 +189,7 @@ class TestTcpAssembler(TestCase):
)
)
- def test_tcp_fpa____init____defaults(self):
+ def test_tcp_fpa____init____defaults(self) -> None:
"""
Test class constructor with default arguments.
"""
@@ -263,97 +263,97 @@ class TestTcpAssembler(TestCase):
b"",
)
- def test_tcp_fpa____init____assert_sport__under(self):
+ def test_tcp_fpa____init____assert_sport__under(self) -> None:
"""
Test assertion for the 'sport' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(sport=-1)
- def test_tcp_fpa____init____assert_sport__over(self):
+ def test_tcp_fpa____init____assert_sport__over(self) -> None:
"""
Test assertion for the 'sport' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(sport=0x10000)
- def test_tcp_fpa____init____assert_dport__under(self):
+ def test_tcp_fpa____init____assert_dport__under(self) -> None:
"""
Test assertion for the 'dport' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(dport=-1)
- def test_tcp_fpa____init____assert_dport__over(self):
+ def test_tcp_fpa____init____assert_dport__over(self) -> None:
"""
Test assertion for the 'dport' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(dport=0x10000)
- def test_tcp_fpa____init____assert_seq__under(self):
+ def test_tcp_fpa____init____assert_seq__under(self) -> None:
"""
Test assertion for the 'seq' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(seq=-1)
- def test_tcp_fpa____init____assert_seq__over(self):
+ def test_tcp_fpa____init____assert_seq__over(self) -> None:
"""
Test assertion for the 'seq' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(seq=0x100000000)
- def test_tcp_fpa____init____assert_ack__under(self):
+ def test_tcp_fpa____init____assert_ack__under(self) -> None:
"""
Test assertion for the 'ack' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(seq=-1)
- def test_tcp_fpa____init____assert_ack__over(self):
+ def test_tcp_fpa____init____assert_ack__over(self) -> None:
"""Test assertion for the ack"""
with self.assertRaises(AssertionError):
TcpAssembler(ack=0x100000000)
- def test_tcp_fpa____init____assert_win__under(self):
+ def test_tcp_fpa____init____assert_win__under(self) -> None:
"""
Test assertion for the 'win' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(win=-1)
- def test_tcp_fpa____init____assert_win__over(self):
+ def test_tcp_fpa____init____assert_win__over(self) -> None:
"""
Test assertion for the 'win' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(win=0x10000)
- def test_tcp_fpa____init____assert_urp__under(self):
+ def test_tcp_fpa____init____assert_urp__under(self) -> None:
"""
Test assertion for the 'urp' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(urp=-1)
- def test_tcp_fpa____init____assert_urp__over(self):
+ def test_tcp_fpa____init____assert_urp__over(self) -> None:
"""
Test assertion for the 'urp' argument.
"""
with self.assertRaises(AssertionError):
TcpAssembler(win=0x10000)
- def test_tcp_fpa____len__(self):
+ def test_tcp_fpa____len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
packet = TcpAssembler()
self.assertEqual(len(packet), TCP_HEADER_LEN)
- def test_tcp_fpa____len____data(self):
+ def test_tcp_fpa____len____data(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -362,7 +362,7 @@ class TestTcpAssembler(TestCase):
)
self.assertEqual(len(packet), TCP_HEADER_LEN + 16)
- def test_tcp_fpa____len____opts(self):
+ def test_tcp_fpa____len____opts(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -376,7 +376,7 @@ class TestTcpAssembler(TestCase):
len(packet), TCP_HEADER_LEN + TCP_OPT_WSCALE_LEN + TCP_OPT_EOL_LEN
)
- def test_tcp_fpa____len____opts_data(self):
+ def test_tcp_fpa____len____opts_data(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -392,7 +392,7 @@ class TestTcpAssembler(TestCase):
TCP_HEADER_LEN + TCP_OPT_WSCALE_LEN + TCP_OPT_EOL_LEN + 16,
)
- def test_tcp_fpa____str__(self):
+ def test_tcp_fpa____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
@@ -433,7 +433,7 @@ class TestTcpAssembler(TestCase):
"ts 12345678/87654321, nop, nop, nop, nop, eol",
)
- def test_tcp_fpa__tracker_getter(self):
+ def test_tcp_fpa__tracker_getter(self) -> None:
"""
Test the 'tracker' property getter.
"""
@@ -442,7 +442,7 @@ class TestTcpAssembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_tcp_fpa___raw_options(self):
+ def test_tcp_fpa___raw_options(self) -> None:
"""
Test the 'options' argument.
"""
@@ -452,7 +452,7 @@ class TestTcpAssembler(TestCase):
self.assertEqual(packet._raw_options, b"\x03\x03\x00\x00")
- def test_tcp_fpa__assemble(self):
+ def test_tcp_fpa__assemble(self) -> None:
"""
Test the 'assemble' method.
"""
@@ -497,28 +497,28 @@ class TestTcpAssembler(TestCase):
class TestTcpOptEol(TestCase):
- def test_tcp_fpa_opt_eol____str__(self):
+ def test_tcp_fpa_opt_eol____str__(self) -> None:
"""Test the __str__ dunder"""
option = TcpOptEol()
self.assertEqual(str(option), "eol")
- def test_tcp_fpa_opt_eol____repr__(self):
+ def test_tcp_fpa_opt_eol____repr__(self) -> None:
"""Test the __repr__ dunder"""
option = TcpOptEol()
self.assertEqual(repr(option), "TcpOptEol()")
- def test_tcp_fpa_opt_eol____bytes__(self):
+ def test_tcp_fpa_opt_eol____bytes__(self) -> None:
"""Test the __bytes__ dunder"""
option = TcpOptEol()
self.assertEqual(bytes(option), b"\x00")
- def test_tcp_fpa_opt_eol____eq__(self):
+ def test_tcp_fpa_opt_eol____eq__(self) -> None:
"""Test the __eq__ dunder"""
option = TcpOptEol()
@@ -527,28 +527,28 @@ class TestTcpOptEol(TestCase):
class TestTcpOptNop(TestCase):
- def test_tcp_fpa_opt_nop____str__(self):
+ def test_tcp_fpa_opt_nop____str__(self) -> None:
"""Test the __str__ dunder"""
option = TcpOptNop()
self.assertEqual(str(option), "nop")
- def test_tcp_fpa_opt_nop____repr__(self):
+ def test_tcp_fpa_opt_nop____repr__(self) -> None:
"""Test the __repr__ dunder"""
option = TcpOptNop()
self.assertEqual(repr(option), "TcpOptNop()")
- def test_tcp_fpa_opt_nop____bytes__(self):
+ def test_tcp_fpa_opt_nop____bytes__(self) -> None:
"""Test the __bytes__ dunder"""
option = TcpOptNop()
self.assertEqual(bytes(option), b"\x01")
- def test_tcp_fpa_opt_nop____eq__(self):
+ def test_tcp_fpa_opt_nop____eq__(self) -> None:
"""Test the __eq__ dunder"""
option = TcpOptNop()
@@ -561,49 +561,49 @@ class TestTcpOptMss(TestCase):
The TCP MSS option unit test class.
"""
- def test_tcp_fpa_opt_mss____init__(self):
+ def test_tcp_fpa_opt_mss____init__(self) -> None:
"""
Test class constructor.
"""
option = TcpOptMss(12345)
self.assertEqual(option._mss, 12345)
- def test_tcp_fpa_opt_mss____init____assert_mss__under(self):
+ def test_tcp_fpa_opt_mss____init____assert_mss__under(self) -> None:
"""
Test assertion for the 'mss' argument.
"""
with self.assertRaises(AssertionError):
TcpOptMss(-1)
- def test_tcp_fpa_opt_mss____init____assert_mss__over(self):
+ def test_tcp_fpa_opt_mss____init____assert_mss__over(self) -> None:
"""
Test assertion for the 'mss' argument.
"""
with self.assertRaises(AssertionError):
TcpOptMss(0x10000)
- def test_tcp_fpa_opt_mss____str__(self):
+ def test_tcp_fpa_opt_mss____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
option = TcpOptMss(12345)
self.assertEqual(str(option), "mss 12345")
- def test_tcp_fpa_opt_mss____repr__(self):
+ def test_tcp_fpa_opt_mss____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = TcpOptMss(12345)
self.assertEqual(repr(option), "TcpOptMss(12345)")
- def test_tcp_fpa_opt_mss____bytes__(self):
+ def test_tcp_fpa_opt_mss____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = TcpOptMss(12345)
self.assertEqual(bytes(option), b"\x02\x0409")
- def test_tcp_fpa_opt_mss____eq__(self):
+ def test_tcp_fpa_opt_mss____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -616,49 +616,49 @@ class TestTcpOptWscale(TestCase):
The TCP WSCALE option unit test class.
"""
- def test_tcp_fpa_opt_wscale____init__(self):
+ def test_tcp_fpa_opt_wscale____init__(self) -> None:
"""
Test class constructor.
"""
option = TcpOptWscale(123)
self.assertEqual(option._wscale, 123)
- def test_tcp_fpa_opt_wscale____init____assert_wscale__under(self):
+ def test_tcp_fpa_opt_wscale____init____assert_wscale__under(self) -> None:
"""
Test assertion for the 'wscale' argument.
"""
with self.assertRaises(AssertionError):
TcpOptWscale(-1)
- def test_tcp_fpa_opt_wscale____init____assert_wscale__over(self):
+ def test_tcp_fpa_opt_wscale____init____assert_wscale__over(self) -> None:
"""
Test assertion for the 'wscale' argument.
"""
with self.assertRaises(AssertionError):
TcpOptWscale(0x100)
- def test_tcp_fpa_opt_wscale____str__(self):
+ def test_tcp_fpa_opt_wscale____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
option = TcpOptWscale(123)
self.assertEqual(str(option), "wscale 123")
- def test_tcp_fpa_opt_wscale____repr__(self):
+ def test_tcp_fpa_opt_wscale____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = TcpOptWscale(123)
self.assertEqual(repr(option), "TcpOptWscale(123)")
- def test_tcp_fpa_opt_wscale____bytes__(self):
+ def test_tcp_fpa_opt_wscale____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = TcpOptWscale(123)
self.assertEqual(bytes(option), b"\x03\x03{")
- def test_tcp_fpa_opt_wscale____eq__(self):
+ def test_tcp_fpa_opt_wscale____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -671,28 +671,28 @@ class TestTcpOptSackPerm(TestCase):
The TCP Sack Permit option unit test class.
"""
- def test_tcp_fpa_opt_sack_perm____str__(self):
+ def test_tcp_fpa_opt_sack_perm____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
option = TcpOptSackPerm()
self.assertEqual(str(option), "sack_perm")
- def test_tcp_fpa_opt_sack_perm____repr__(self):
+ def test_tcp_fpa_opt_sack_perm____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = TcpOptSackPerm()
self.assertEqual(repr(option), "TcpOptSackPerm()")
- def test_tcp_fpa_opt_sack_perm____bytes__(self):
+ def test_tcp_fpa_opt_sack_perm____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = TcpOptSackPerm()
self.assertEqual(bytes(option), b"\x04\x02")
- def test_tcp_fpa_opt_sack_perm____eq__(self):
+ def test_tcp_fpa_opt_sack_perm____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""
@@ -705,7 +705,7 @@ class TestTcpOptTimestamp(TestCase):
The TCP Timestamp option unit test class.
"""
- def test_tcp_fpa_opt_timestamp____init__(self):
+ def test_tcp_fpa_opt_timestamp____init__(self) -> None:
"""
Test class constructor.
"""
@@ -713,56 +713,56 @@ class TestTcpOptTimestamp(TestCase):
self.assertEqual(option._tsval, 12345678)
self.assertEqual(option._tsecr, 87654321)
- def test_tcp_fpa_opt_timestamp____init____assert_tsval__under(self):
+ def test_tcp_fpa_opt_timestamp____init____assert_tsval__under(self) -> None:
"""
Test assertion for the 'tsval' argument.
"""
with self.assertRaises(AssertionError):
TcpOptTimestamp(-1, 0)
- def test_tcp_fpa_opt_timestamp____init____assert_tsval__over(self):
+ def test_tcp_fpa_opt_timestamp____init____assert_tsval__over(self) -> None:
"""
Test assertion for the 'tsval' argument.
"""
with self.assertRaises(AssertionError):
TcpOptTimestamp(0x100000000, 0)
- def test_tcp_fpa_opt_timestamp____init____assert_tsecr__under(self):
+ def test_tcp_fpa_opt_timestamp____init____assert_tsecr__under(self) -> None:
"""
Test assertion for the 'tsecr' argument.
"""
with self.assertRaises(AssertionError):
TcpOptTimestamp(0, -1)
- def test_tcp_fpa_opt_timestamp____init____assert_tsecr__over(self):
+ def test_tcp_fpa_opt_timestamp____init____assert_tsecr__over(self) -> None:
"""
Test assertion for the 'tsecr' argument.
"""
with self.assertRaises(AssertionError):
TcpOptTimestamp(0, 0x100000000)
- def test_tcp_fpa_opt_timestamp____str__(self):
+ def test_tcp_fpa_opt_timestamp____str__(self) -> None:
"""
Test the '__str__()' dunder.
"""
option = TcpOptTimestamp(12345678, 87654321)
self.assertEqual(str(option), "ts 12345678/87654321")
- def test_tcp_fpa_opt_timestamp____repr__(self):
+ def test_tcp_fpa_opt_timestamp____repr__(self) -> None:
"""
Test the '__repr__()' dunder.
"""
option = TcpOptTimestamp(12345678, 87654321)
self.assertEqual(repr(option), "TcpOptTimestamp(12345678, 87654321)")
- def test_tcp_fpa_opt_timestamp____bytes__(self):
+ def test_tcp_fpa_opt_timestamp____bytes__(self) -> None:
"""
Test the '__bytes__()' dunder.
"""
option = TcpOptTimestamp(12345678, 87654321)
self.assertEqual(bytes(option), b"\x08\n\x00\xbcaN\x059\x7f\xb1")
- def test_tcp_fpa_opt_timestamp____eq__(self):
+ def test_tcp_fpa_opt_timestamp____eq__(self) -> None:
"""
Test the '__eq__()' dunder.
"""

diff --git a/tests/unit/tcp_phtx.py b/tests/unit/tcp_phtx.py
index 5bc1060..3a0fa82 100755
--- a/tests/unit/tcp_phtx.py
+++ b/tests/unit/tcp_phtx.py
@@ -50,7 +50,7 @@ class TestUdpPhtx(TestCase):
UDP packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Set up the test environment.
"""
@@ -61,7 +61,7 @@ class TestUdpPhtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_tcp_phtx__ip4_tcp_packet(self):
+ def test_tcp_phtx__ip4_tcp_packet(self) -> None:
"""
Test sending the IPv4/TCP packet.
"""
@@ -89,7 +89,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__seq(self):
+ def test_tcp_phtx__ip4_tcp_packet__seq(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'seq' field.
"""
@@ -118,7 +118,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__ack(self):
+ def test_tcp_phtx__ip4_tcp_packet__ack(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'ack' field.
"""
@@ -147,7 +147,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__ns(self):
+ def test_tcp_phtx__ip4_tcp_packet__ns(self) -> None:
"""
Test sending Ithe Pv4/TCP packet with set 'flag_ns' field.
"""
@@ -177,7 +177,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__flag_crw(self):
+ def test_tcp_phtx__ip4_tcp_packet__flag_crw(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'flag_crw' field.
"""
@@ -207,7 +207,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__flag_ece(self):
+ def test_tcp_phtx__ip4_tcp_packet__flag_ece(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'flag_ece' field.
"""
@@ -237,7 +237,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__flag_urg(self):
+ def test_tcp_phtx__ip4_tcp_packet__flag_urg(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'flag_urg' field.
"""
@@ -267,7 +267,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__flag_ack(self):
+ def test_tcp_phtx__ip4_tcp_packet__flag_ack(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'flag_ack' field.
"""
@@ -297,7 +297,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__flag_psh(self):
+ def test_tcp_phtx__ip4_tcp_packet__flag_psh(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'flag_psh' field.
"""
@@ -327,7 +327,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__flag_rst(self):
+ def test_tcp_phtx__ip4_tcp_packet__flag_rst(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'flag_rst' field.
"""
@@ -357,7 +357,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__flag_syn(self):
+ def test_tcp_phtx__ip4_tcp_packet__flag_syn(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'flag_syn' field.
"""
@@ -387,7 +387,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__win(self):
+ def test_tcp_phtx__ip4_tcp_packet__win(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'win' field.
"""
@@ -416,7 +416,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__urp(self):
+ def test_tcp_phtx__ip4_tcp_packet__urp(self) -> None:
"""
Test sending the IPv4/TCP packet with set 'urp' field.
"""
@@ -445,7 +445,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_udp_phtx__ip4_tcp_packet__data(self):
+ def test_udp_phtx__ip4_tcp_packet__data(self) -> None:
"""
Test sending the IPv4/TCPP packet with data.
"""
@@ -474,7 +474,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__ip6_src(self):
+ def test_tcp_phtx__ip4_tcp_packet__ip6_src(self) -> None:
"""
Test sending the IPv4/TCP packet with 'src' set to IPv6 address.
"""
@@ -493,7 +493,7 @@ class TestUdpPhtx(TestCase):
),
)
- def test_tcp_phtx__ip4_tcp_packet__ip6_dst(self):
+ def test_tcp_phtx__ip4_tcp_packet__ip6_dst(self) -> None:
"""
Test sending the IPv6/TCP packet with 'dst' set to IPv6 address.
"""
@@ -512,7 +512,7 @@ class TestUdpPhtx(TestCase):
),
)
- def test_tcp_phtx__ip4_tcp_packet__mss(self):
+ def test_tcp_phtx__ip4_tcp_packet__mss(self) -> None:
"""
Test sending Ithe Pv4/TCP packet with 'MSS' option.
"""
@@ -542,7 +542,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip4_tcp_packet__wscale(self):
+ def test_tcp_phtx__ip4_tcp_packet__wscale(self) -> None:
"""
Test sending the IPv4/TCP packet with 'WSCALE' option.
"""
@@ -573,7 +573,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet(self):
+ def test_tcp_phtx__ip6_tcp_packet(self) -> None:
"""
Test sending the IPv6/TCP packet.
"""
@@ -601,7 +601,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__seq(self):
+ def test_tcp_phtx__ip6_tcp_packet__seq(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'seq' field.
"""
@@ -630,7 +630,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__ack(self):
+ def test_tcp_phtx__ip6_tcp_packet__ack(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'ack' field.
"""
@@ -659,7 +659,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__ns(self):
+ def test_tcp_phtx__ip6_tcp_packet__ns(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_ns' field.
"""
@@ -689,7 +689,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__flag_crw(self):
+ def test_tcp_phtx__ip6_tcp_packet__flag_crw(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_crw' field.
"""
@@ -719,7 +719,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__flag_ece(self):
+ def test_tcp_phtx__ip6_tcp_packet__flag_ece(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_ece' field.
"""
@@ -749,7 +749,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__flag_urg(self):
+ def test_tcp_phtx__ip6_tcp_packet__flag_urg(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_urg' field.
"""
@@ -779,7 +779,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__flag_ack(self):
+ def test_tcp_phtx__ip6_tcp_packet__flag_ack(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_ack' field.
"""
@@ -809,7 +809,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__flag_psh(self):
+ def test_tcp_phtx__ip6_tcp_packet__flag_psh(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_psh' field.
"""
@@ -839,7 +839,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__flag_rst(self):
+ def test_tcp_phtx__ip6_tcp_packet__flag_rst(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_rst' field.
"""
@@ -869,7 +869,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__flag_syn(self):
+ def test_tcp_phtx__ip6_tcp_packet__flag_syn(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'flag_syn' field.
"""
@@ -899,7 +899,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__win(self):
+ def test_tcp_phtx__ip6_tcp_packet__win(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'win' field.
"""
@@ -928,7 +928,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__urp(self):
+ def test_tcp_phtx__ip6_tcp_packet__urp(self) -> None:
"""
Test sending the IPv6/TCP packet with set 'urp' field.
"""
@@ -957,7 +957,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__data(self):
+ def test_tcp_phtx__ip6_tcp_packet__data(self) -> None:
"""
Test sending the IPv6/TCP packet with data.
"""
@@ -986,7 +986,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_tcp_phtx__ip6_tcp_packet__ip4_src(self):
+ def test_tcp_phtx__ip6_tcp_packet__ip4_src(self) -> None:
"""
Test sending the IPv6/TCP packet with 'src' set to IPv4 address.
"""
@@ -1005,7 +1005,7 @@ class TestUdpPhtx(TestCase):
),
)
- def test_tcp_phtx__ip6_tcp_packet__ip4_dst(self):
+ def test_tcp_phtx__ip6_tcp_packet__ip4_dst(self) -> None:
"""
Test sending the IPv6/TCP packet with 'dst' set to IPv6 address.
"""

diff --git a/tests/unit/udp_fpa.py b/tests/unit/udp_fpa.py
index 320fa62..e304d78 100755
--- a/tests/unit/udp_fpa.py
+++ b/tests/unit/udp_fpa.py
@@ -45,21 +45,21 @@ class TestUdpAssembler(TestCase):
UDP packet assembler unit test class.
"""
- def test_udp_fpa__ip4_proto_udp(self):
+ def test_udp_fpa__ip4_proto_udp(self) -> None:
"""
Make sure the 'UdpAssembler' class has the proper
'ip4_proto' value assigned.
"""
self.assertEqual(UdpAssembler.ip4_proto, IP4_PROTO_UDP)
- def test_udp_fpa__ip6_next_udp(self):
+ def test_udp_fpa__ip6_next_udp(self) -> None:
"""
Make sure the 'UdpAssembler' class has the proper
'ip6_next' value assigned.
"""
self.assertEqual(UdpAssembler.ip6_next, IP6_NEXT_UDP)
- def test_udp_fpa____init__(self):
+ def test_udp_fpa____init__(self) -> None:
"""
Test class constructor.
"""
@@ -79,7 +79,7 @@ class TestUdpAssembler(TestCase):
)
)
- def test_udp_fpa____init____defaults(self):
+ def test_udp_fpa____init____defaults(self) -> None:
"""
Test class constructor with default arguments.
"""
@@ -89,42 +89,42 @@ class TestUdpAssembler(TestCase):
self.assertEqual(packet._data, b"")
self.assertEqual(packet._plen, UDP_HEADER_LEN)
- def test_udp_fpa____init____assert_sport__under(self):
+ def test_udp_fpa____init____assert_sport__under(self) -> None:
"""
Test assertion for the 'sport' argument.
"""
with self.assertRaises(AssertionError):
UdpAssembler(sport=-1)
- def test_udp_fpa____init____assert_sport__over(self):
+ def test_udp_fpa____init____assert_sport__over(self) -> None:
"""
Test assertion for the 'sport'
"""
with self.assertRaises(AssertionError):
UdpAssembler(sport=0x10000)
- def test_udp_fpa____init____assert_dport__under(self):
+ def test_udp_fpa____init____assert_dport__under(self) -> None:
"""
Test assertion for the 'dport'.
"""
with self.assertRaises(AssertionError):
UdpAssembler(dport=-1)
- def test_udp_fpa____init____assert_dport__over(self):
+ def test_udp_fpa____init____assert_dport__over(self) -> None:
"""
Test assertion for the dport.
"""
with self.assertRaises(AssertionError):
UdpAssembler(dport=0x10000)
- def test_udp_fpa____len__(self):
+ def test_udp_fpa____len__(self) -> None:
"""
Test the '__len__()' dunder.
"""
packet = UdpAssembler()
self.assertEqual(len(packet), UDP_HEADER_LEN)
- def test_udp_fpa____len____data(self):
+ def test_udp_fpa____len____data(self) -> None:
"""
Test the '__len__()' dunder.
"""
@@ -134,7 +134,7 @@ class TestUdpAssembler(TestCase):
self.assertEqual(len(packet), UDP_HEADER_LEN + 16)
- def test_udp_fpa____str__(self):
+ def test_udp_fpa____str__(self) -> None:
"""
Test the '__str__() dunder.
"""
@@ -145,7 +145,7 @@ class TestUdpAssembler(TestCase):
)
self.assertEqual(str(packet), "UDP 12345 > 54321, len 24")
- def test_udp_fpa__tracker_getter(self):
+ def test_udp_fpa__tracker_getter(self) -> None:
"""
Test the tracker property.
"""
@@ -154,7 +154,7 @@ class TestUdpAssembler(TestCase):
repr(packet.tracker).startswith("Tracker(serial='<lr>TX")
)
- def test_udp_fpa__assemble(self):
+ def test_udp_fpa__assemble(self) -> None:
"""
Test the 'assemble()' method.
"""

diff --git a/tests/unit/udp_phtx.py b/tests/unit/udp_phtx.py
index de18037..c4ab8d2 100755
--- a/tests/unit/udp_phtx.py
+++ b/tests/unit/udp_phtx.py
@@ -50,7 +50,7 @@ class TestUdpPhtx(TestCase):
UDP packet handler TX unit test class.
"""
- def setUp(self):
+ def setUp(self) -> None:
"""
Set up the test environment.
"""
@@ -61,7 +61,7 @@ class TestUdpPhtx(TestCase):
# Test name format: 'test_name__test_description__optional_condition'
- def test_udp_phtx__ip4_udp_packet(self):
+ def test_udp_phtx__ip4_udp_packet(self) -> None:
"""
Test sending the IPv4/UDP packet with no data.
"""
@@ -90,7 +90,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_udp_phtx__ip4_udp_packet__data(self):
+ def test_udp_phtx__ip4_udp_packet__data(self) -> None:
"""Test sending IPv4/UDP packet with data"""
tx_status = self.packet_handler._phtx_udp(
@@ -118,7 +118,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_udp_phtx__ip4_udp_packet__ip6_src(self):
+ def test_udp_phtx__ip4_udp_packet__ip6_src(self) -> None:
"""Test sending IPv4/UDP packet with src set to ip6 address"""
tx_status = self.packet_handler._phtx_udp(
@@ -136,7 +136,7 @@ class TestUdpPhtx(TestCase):
),
)
- def test_udp_phtx__ip4_udp_packet__ip6_dst(self):
+ def test_udp_phtx__ip4_udp_packet__ip6_dst(self) -> None:
"""Test sending IPv6/UDP packet with dst set to ip4 address"""
tx_status = self.packet_handler._phtx_udp(
@@ -154,7 +154,7 @@ class TestUdpPhtx(TestCase):
),
)
- def test_udp_phtx__ip6_udp_packet(self):
+ def test_udp_phtx__ip6_udp_packet(self) -> None:
"""Test sending IPv6/UDP packet with no data"""
tx_status = self.packet_handler._phtx_udp(
@@ -181,7 +181,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_udp_phtx__ip6_udp_packet__data(self):
+ def test_udp_phtx__ip6_udp_packet__data(self) -> None:
"""Test sending IPv6/UDP packet with data"""
tx_status = self.packet_handler._phtx_udp(
@@ -209,7 +209,7 @@ class TestUdpPhtx(TestCase):
frame_tx = _.read()
self.assertEqual(self.frame_tx[: len(frame_tx)], frame_tx)
- def test_udp_phtx__ip6_udp_packet__ip4_src(self):
+ def test_udp_phtx__ip6_udp_packet__ip4_src(self) -> None:
"""Test sending IPv6/UDP packet with src set to ip4 address"""
tx_status = self.packet_handler._phtx_udp(
@@ -227,7 +227,7 @@ class TestUdpPhtx(TestCase):
),
)
- def test_udp_phtx__ip6_udp_packet__ip4_dst(self):
+ def test_udp_phtx__ip6_udp_packet__ip4_dst(self) -> None:
"""Test sending IPv6/UDP packet with dst set to ip4 address"""
tx_status = self.packet_handler._phtx_udp(

Served by rngit 1.5.0 - Generated in 0.4s